Skip to content

Commit d610363

Browse files
author
git apple-llvm automerger
committed
Merge commit '015ab4e2e4a7' from llvm.org/main into next
2 parents 1ded2dd + 015ab4e commit d610363

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/lib/Transforms/Scalar/Reassociate.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,8 +1513,11 @@ Value *ReassociatePass::OptimizeAdd(Instruction *I,
15131513

15141514
// Insert a new multiply.
15151515
Type *Ty = TheOp->getType();
1516-
Constant *C = Ty->isIntOrIntVectorTy() ?
1517-
ConstantInt::get(Ty, NumFound) : ConstantFP::get(Ty, NumFound);
1516+
// Truncate if NumFound overflows the type.
1517+
Constant *C = Ty->isIntOrIntVectorTy()
1518+
? ConstantInt::get(Ty, NumFound, /*IsSigned=*/false,
1519+
/*ImplicitTrunc=*/true)
1520+
: ConstantFP::get(Ty, NumFound);
15181521
Instruction *Mul = CreateMul(TheOp, C, "factor", I->getIterator(), I);
15191522
Mul->setDebugLoc(I->getDebugLoc());
15201523

0 commit comments

Comments
 (0)