forked from OSchip/llvm-project
[InstCombine] reduce code duplication for FP min/max with casts fold; NFC
This commit is contained in:
parent
bfd172999b
commit
b1f6ef92ec
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue