[PATCH] D137822: [IRCE] Bail out if Start AddRec is for another loop
Dmitry Makogon via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 11 02:51:28 PST 2022
dmakogon created this revision.
dmakogon added reviewers: fhahn, mkazantsev, jaykang10, samparker.
Herald added a subscriber: hiraditya.
Herald added a project: All.
dmakogon requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Imagine we have an outer loop and an inner loop, which is in the outer one, and a range check in outer loop of such addrec:
{{0,+,1}<%outer_header>,+,1}<%inner_header>
When IRCE runs on the outer loop it sees the range check and tries to check whether it is possible to safely calculate the loop bound.
However, this addrec is for the inner loop, so we shouldn't do anything at all.
Fixes https://github.com/llvm/llvm-project/issues/58912
https://reviews.llvm.org/D137822
Files:
llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
llvm/test/Transforms/IRCE/iv-for-another-loop.ll
Index: llvm/test/Transforms/IRCE/iv-for-another-loop.ll
===================================================================
--- llvm/test/Transforms/IRCE/iv-for-another-loop.ll
+++ llvm/test/Transforms/IRCE/iv-for-another-loop.ll
@@ -4,7 +4,7 @@
target triple = "x86_64-unknown-linux-gnu"
; REQUIRES: asserts
-; XFAIL: *
+; CHECK-NOT: irce
define void @test() {
bb:
Index: llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
+++ llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
@@ -845,6 +845,10 @@
// induction variable satisfies some constraint.
const SCEVAddRecExpr *IndVarBase = cast<SCEVAddRecExpr>(LeftSCEV);
+ if (IndVarBase->getLoop() != &L) {
+ FailureReason = "LHS in icmp not induction variable for this loop";
+ return None;
+ }
if (!IndVarBase->isAffine()) {
FailureReason = "LHS in icmp not induction variable";
return None;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137822.474691.patch
Type: text/x-patch
Size: 1033 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221111/3862326a/attachment.bin>
More information about the llvm-commits
mailing list