[PATCH] D87854: [SCEV] Use information from assume for BE taken count.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 11:20:54 PDT 2020
fhahn updated this revision to Diff 294372.
fhahn added a comment.
In D87854#2280261 <https://reviews.llvm.org/D87854#2280261>, @jdoerfert wrote:
> commit message?
It was not quite ready yet, but now everything should be in place and this patch only contains the important change. I'll update the title/description shortly after updating the diff.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87854/new/
https://reviews.llvm.org/D87854
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll
Index: llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll
===================================================================
--- llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll
+++ llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll
@@ -278,7 +278,7 @@
define void @test_guard_and_assume(i32* nocapture readonly %data, i64 %count) {
; CHECK-LABEL: @test_guard_and_assume
; CHECK: Loop %loop: backedge-taken count is (-1 + %count)
-; CHECK-NEXT: Loop %loop: max backedge-taken count is -2
+; CHECK-NEXT: Loop %loop: max backedge-taken count is 3
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %count)
;
entry:
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -12658,6 +12658,18 @@
getSCEV(Cmp->getOperand(1)), RewriteMap);
}
+ // Also collect information from assumptions dominating the loop.
+ for (auto &AssumeVH : AC.assumptions()) {
+ if (!AssumeVH)
+ continue;
+ auto *AssumeI = cast<CallInst>(AssumeVH);
+ auto *Cmp = dyn_cast<ICmpInst>(AssumeI->getOperand(0));
+ if (!Cmp || !DT.dominates(AssumeI, L->getHeader()))
+ continue;
+ CollectCondition(Cmp->getPredicate(), getSCEV(Cmp->getOperand(0)),
+ getSCEV(Cmp->getOperand(1)), RewriteMap);
+ }
+
if (RewriteMap.empty())
return Expr;
return SCEVParameterRewriter::rewrite(Expr, *this, RewriteMap);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87854.294372.patch
Type: text/x-patch
Size: 1597 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200925/2e0d99b6/attachment.bin>
More information about the llvm-commits
mailing list