[llvm] [SCEVExpander] Expand UDiv avoiding UB when in seq_min/max. (PR #92177)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 02:18:07 PDT 2024
================
@@ -676,7 +676,15 @@ Value *SCEVExpander::visitUDivExpr(const SCEVUDivExpr *S) {
SCEV::FlagAnyWrap, /*IsSafeToHoist*/ true);
}
- Value *RHS = expand(S->getRHS());
+ const SCEV *RHSExpr = S->getRHS();
+ Value *RHS = expand(RHSExpr);
+ if (SafeUDivMode &&
+ (!isa<SCEVConstant>(RHSExpr) || SE.isKnownNonZero(RHSExpr))) {
+ if (!isa<SCEVConstant>(S->getRHS()))
----------------
nikic wrote:
This can now use the isGuaranteedNotToBePoison check instead.
https://github.com/llvm/llvm-project/pull/92177
More information about the llvm-commits
mailing list