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;
|
// m((fpext X), (fpext Y)) -> fpext (m(X, Y))
|
||||||
Value *ExtSrc1;
|
if (match(Arg0, m_OneUse(m_FPExt(m_Value(X)))) &&
|
||||||
|
match(Arg1, m_OneUse(m_FPExt(m_Value(Y)))) &&
|
||||||
// minnum (fpext x), (fpext y) -> minnum x, y
|
X->getType() == Y->getType()) {
|
||||||
// maxnum (fpext x), (fpext y) -> maxnum x, y
|
Value *NewCall =
|
||||||
if (match(II->getArgOperand(0), m_OneUse(m_FPExt(m_Value(ExtSrc0)))) &&
|
Builder.CreateBinaryIntrinsic(IID, X, Y, II, II->getName());
|
||||||
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);
|
|
||||||
return new FPExtInst(NewCall, II->getType());
|
return new FPExtInst(NewCall, II->getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue