[llvm] [LV] Don't vectorize if trip count expansion may introduce UB. (PR #92177)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Tue May 14 14:37:01 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:
Is this the same as SafeToHoist in SCEVExpander::expand?
We could probably do something more clever if it mattered: the only way for the exit count to contain UB is if the branch never executes, so it would be correct to just transform `a/b` to `a/umax(b, 1)`.
https://github.com/llvm/llvm-project/pull/92177
More information about the llvm-commits
mailing list