1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[InstCombine] reduce code duplication for FP min/max with casts fold; NFC

This commit is contained in:
Sanjay Patel 2021-06-22 13:42:44 -04:00
parent d78c67e231
commit 296b173595

View File

@ -1367,19 +1367,12 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
}
}
Value *ExtSrc0;
Value *ExtSrc1;
// minnum (fpext x), (fpext y) -> minnum x, y
// maxnum (fpext x), (fpext y) -> maxnum x, y
if (match(II->getArgOperand(0), m_OneUse(m_FPExt(m_Value(ExtSrc0)))) &&
match(II->getArgOperand(1), m_OneUse(m_FPExt(m_Value(ExtSrc1)))) &&
ExtSrc0->getType() == ExtSrc1->getType()) {
Function *F = Intrinsic::getDeclaration(
II->getModule(), II->getIntrinsicID(), {ExtSrc0->getType()});
CallInst *NewCall = Builder.CreateCall(F, { ExtSrc0, ExtSrc1 });
NewCall->copyFastMathFlags(II);
NewCall->takeName(II);
// m((fpext X), (fpext Y)) -> fpext (m(X, Y))
if (match(Arg0, m_OneUse(m_FPExt(m_Value(X)))) &&
match(Arg1, m_OneUse(m_FPExt(m_Value(Y)))) &&
X->getType() == Y->getType()) {
Value *NewCall =
Builder.CreateBinaryIntrinsic(IID, X, Y, II, II->getName());
return new FPExtInst(NewCall, II->getType());
}