[llvm] [SCEVExpander] Expand UDiv avoiding UB when in seq_min/max. (PR #92177)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 15 11:14:43 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)) {
----------------
efriedma-quic wrote:

isKnownNonZero doesn't check for poison, I think.

https://github.com/llvm/llvm-project/pull/92177


More information about the llvm-commits mailing list