[llvm] [SCEVExpander] Expand UDiv avoiding UB when in seq_min/max. (PR #92177)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 23:46:40 PDT 2024
================
@@ -676,7 +676,14 @@ 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 && !SE.isKnownNonZero(RHSExpr)) {
----------------
fhahn wrote:
Added and updated to separately check for !poison -> emit freeze, !known-non-zero -> emit umax
https://github.com/llvm/llvm-project/pull/92177
More information about the llvm-commits
mailing list