[llvm] [ScalarEvolutionExpander] Use IRBuilder::CreateBinOp in SCEVExpander::InsertBinop. (PR #146443)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 03:29:04 PDT 2025
================
@@ -315,14 +315,14 @@ Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode,
}
// If we haven't found this binop, insert it.
- // TODO: Use the Builder, which will make CreateBinOp below fold with
- // InstSimplifyFolder.
- Instruction *BO = Builder.Insert(BinaryOperator::Create(Opcode, LHS, RHS));
- BO->setDebugLoc(Loc);
- if (Flags & SCEV::FlagNUW)
- BO->setHasNoUnsignedWrap();
- if (Flags & SCEV::FlagNSW)
- BO->setHasNoSignedWrap();
+ Value *BO = Builder.CreateBinOp(Opcode, LHS, RHS);
+ if (auto *BOI = dyn_cast<Instruction>(BO)) {
+ BOI->setDebugLoc(Loc);
+ if (Flags & SCEV::FlagNUW)
+ BOI->setHasNoUnsignedWrap();
+ if (Flags & SCEV::FlagNSW)
+ BOI->setHasNoSignedWrap();
----------------
nikic wrote:
You can't set flags after the fact with InstSimplifyFolder. You need to add a new IRBuilder method like CreateNoWrapBinOp that accepts the flags as arguments.
https://github.com/llvm/llvm-project/pull/146443
More information about the llvm-commits
mailing list