[llvm] LICM: extend hoist BO assoc to mul case (PR #106991)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 3 07:31:07 PDT 2024
================
@@ -2841,15 +2841,18 @@ static bool hoistBOAssociation(Instruction &I, Loop &L,
auto *Preheader = L.getLoopPreheader();
assert(Preheader && "Loop is not in simplify form?");
- auto *Inv = BinaryOperator::Create(Opcode, C1, C2, "invariant.op",
- Preheader->getTerminator()->getIterator());
+ IRBuilder<> Builder(Preheader->getTerminator());
+ auto *Inv = Builder.CreateBinOp(Opcode, C1, C2, "invariant.op");
+
auto *NewBO = BinaryOperator::Create(
Opcode, LV, Inv, BO->getName() + ".reass", BO->getIterator());
// Copy NUW for ADDs if both instructions have it.
if (Opcode == Instruction::Add && BO->hasNoUnsignedWrap() &&
BO0->hasNoUnsignedWrap()) {
- Inv->setHasNoUnsignedWrap(true);
+ // If the constant-folder didn't kick in, and a new Instruction was created.
----------------
artagnon wrote:
Thanks, fixed in #106978.
https://github.com/llvm/llvm-project/pull/106991
More information about the llvm-commits
mailing list