[llvm] [LV] Rewrite UDiv A, B -> UDiv A, UMax(B, 1) in trip counts if needed. (PR #92177)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 14:10:24 PDT 2024


================
@@ -161,6 +161,11 @@ SCEVExpander::findInsertPointAfter(Instruction *I,
   return IP;
 }
 
+bool SCEVExpander::expansionMayIntroduceUB(const SCEV *Expr) {
+  return SCEVExprContains(Expr,
+                          [](const SCEV *Op) { return isa<SCEVUDivExpr>(Op); });
----------------
efriedma-quic wrote:

There's one more case here I wasn't thinking about: udiv where the RHS is poison.  umax isn't sufficient in that case because umax(1,poison) is still poison,

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


More information about the llvm-commits mailing list