[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:41:25 PDT 2024
================
@@ -1358,11 +1364,13 @@ Value *SCEVExpander::visitSignExtendExpr(const SCEVSignExtendExpr *S) {
Value *SCEVExpander::expandMinMaxExpr(const SCEVNAryExpr *S,
Intrinsic::ID IntrinID, Twine Name,
bool IsSequential) {
+ SafeUDivMode = true;
Value *LHS = expand(S->getOperand(S->getNumOperands() - 1));
Type *Ty = LHS->getType();
if (IsSequential)
LHS = Builder.CreateFreeze(LHS);
for (int i = S->getNumOperands() - 2; i >= 0; --i) {
+ SafeUDivMode = i != 0;
----------------
fhahn wrote:
Updated to save the initial mode, and updated the code to not set it to false if it was already set.
And restored the original value on exit.
The earlier version was also enabling it if IsSequential was false. Also fixed
https://github.com/llvm/llvm-project/pull/92177
More information about the llvm-commits
mailing list