[PATCH] D126503: [SCEV] Use fact that B >u 0 for A <u B in applyLoopGuards.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 1 06:16:11 PST 2023
fhahn marked an inline comment as done.
fhahn added inline comments.
================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:14481
RewrittenRHS =
getSMinExpr(RewrittenLHS, getMinusSCEV(RHS, getOne(RHS->getType())));
break;
----------------
mkazantsev wrote:
> I think there should be (maybe not such useful, but still) a symmetrical signed case with `SINT_MIN+1` instead of `1`.
I'll investigate as follow-up.
================
Comment at: llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll:386
; CHECK-NEXT: Loop %loop: backedge-taken count is %N
-; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
+; CHECK-NEXT: Loop %loop: max backedge-taken count is -3
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is %N
----------------
mkazantsev wrote:
> I wonder, how come that AddRec is now proven to make just 1 iteration less, but BE taken count is reduced by 2? It's not necessarily a bug, but looks strange.
The loop is guarded by `%N < %I` and `%I < %N` which cannot both be true, so it should never execute.
The reason we adjust the count by 2 is because we do the following substitutions
i = min(i, N-1)
N = min(N, min(I, N-1) -1)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126503/new/
https://reviews.llvm.org/D126503
More information about the llvm-commits
mailing list