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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 27 13:20:50 PDT 2024


================
@@ -4304,12 +4304,19 @@ ScalarEvolution::getSequentialMinMaxExpr(SCEVTypes Kind,
   }
 
   for (unsigned i = 1, e = Ops.size(); i != e; ++i) {
+    bool MayBeUB = SCEVExprContains(Ops[i], [](const SCEV *S) {
+      auto *UDiv = dyn_cast<SCEVUDivExpr>(S);
+      return UDiv && !isa<SCEVConstant>(UDiv->getOperand(1));
----------------
fhahn wrote:

Updated to check for `!isKnownNonZero()` and added comment, thanks!

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


More information about the llvm-commits mailing list