[llvm] [SCEVExp] Use Builder.CreateBinOp in InsertBinOp. (PR #154148)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 19 05:42:42 PDT 2025
================
@@ -317,16 +317,16 @@ 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();
-
- return BO;
+ Value *Op = Builder.CreateBinOp(Opcode, LHS, RHS);
+ if (auto *BO = dyn_cast<Instruction>(Op)) {
+ BO->setDebugLoc(Loc);
+ if (Flags & SCEV::FlagNUW)
+ BO->setHasNoUnsignedWrap();
+ if (Flags & SCEV::FlagNSW)
+ BO->setHasNoSignedWrap();
----------------
fhahn wrote:
Yeah, looks like we where missing test coverage for that, added in 1217c8226b09657800bb8711e2be49a143de9dca.
Had to add a new `CreateBinOpNoWrapFlags`
https://github.com/llvm/llvm-project/pull/154148
More information about the llvm-commits
mailing list