Skip to content

Commit 25af06f

Browse files
committed
[InstCombine] Avoid use of FP cast constant expressions (NFC)
Use the constant folding API instead. As we're working on plain ConstantFP, this should always succeed.
1 parent fe6893b commit 25af06f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,10 +1841,11 @@ Instruction *InstCombinerImpl::visitFAdd(BinaryOperator &I) {
18411841
// instcombined.
18421842
if (ConstantFP *CFP = dyn_cast<ConstantFP>(RHS))
18431843
if (IsValidPromotion(FPType, LHSIntVal->getType())) {
1844-
Constant *CI =
1845-
ConstantExpr::getFPToSI(CFP, LHSIntVal->getType());
1844+
Constant *CI = ConstantFoldCastOperand(Instruction::FPToSI, CFP,
1845+
LHSIntVal->getType(), DL);
18461846
if (LHSConv->hasOneUse() &&
1847-
ConstantExpr::getSIToFP(CI, I.getType()) == CFP &&
1847+
ConstantFoldCastOperand(Instruction::SIToFP, CI, I.getType(), DL) ==
1848+
CFP &&
18481849
willNotOverflowSignedAdd(LHSIntVal, CI, I)) {
18491850
// Insert the new integer add.
18501851
Value *NewAdd = Builder.CreateNSWAdd(LHSIntVal, CI, "addconv");

0 commit comments

Comments
 (0)