[PATCH] D56812: [LoopReroll] Fix reroll root legality checking.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 11 16:33:00 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353779: [LoopReroll] Fix reroll root legality checking. (authored by efriedma, committed by ).
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D56812?vs=182160&id=186366#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56812/new/
https://reviews.llvm.org/D56812
Files:
llvm/trunk/lib/Transforms/Scalar/LoopRerollPass.cpp
llvm/trunk/test/Transforms/LoopReroll/basic.ll
Index: llvm/trunk/test/Transforms/LoopReroll/basic.ll
===================================================================
--- llvm/trunk/test/Transforms/LoopReroll/basic.ll
+++ llvm/trunk/test/Transforms/LoopReroll/basic.ll
@@ -785,6 +785,30 @@
ret void
}
+define void @bad_step(i32* nocapture readnone %x) #0 {
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %i.08 = phi i32 [ 0, %entry ], [ %add3, %for.body ]
+ %call = tail call i32 @foo(i32 %i.08) #1
+ %add = add nsw i32 %i.08, 2
+ %call1 = tail call i32 @foo(i32 %add) #1
+ %add2 = add nsw i32 %i.08, 3
+ %call3 = tail call i32 @foo(i32 %add2) #1
+ %add3 = add nsw i32 %i.08, 6
+ %exitcond = icmp sge i32 %add3, 500
+ br i1 %exitcond, label %for.end, label %for.body
+
+; CHECK-LABEL: @bad_step
+; CHECK: %add = add nsw i32 %i.08, 2
+; CHECK: %add2 = add nsw i32 %i.08, 3
+; CHECK: %add3 = add nsw i32 %i.08, 6
+
+for.end: ; preds = %for.body
+ ret void
+}
+
attributes #0 = { nounwind uwtable }
attributes #1 = { nounwind }
Index: llvm/trunk/lib/Transforms/Scalar/LoopRerollPass.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopRerollPass.cpp
+++ llvm/trunk/lib/Transforms/Scalar/LoopRerollPass.cpp
@@ -891,12 +891,22 @@
const auto *ADR = dyn_cast<SCEVAddRecExpr>(SE->getSCEV(DRS.BaseInst));
if (!ADR)
return false;
+
+ // Check that the first root is evenly spaced.
unsigned N = DRS.Roots.size() + 1;
const SCEV *StepSCEV = SE->getMinusSCEV(SE->getSCEV(DRS.Roots[0]), ADR);
const SCEV *ScaleSCEV = SE->getConstant(StepSCEV->getType(), N);
if (ADR->getStepRecurrence(*SE) != SE->getMulExpr(StepSCEV, ScaleSCEV))
return false;
+ // Check that the remainling roots are evenly spaced.
+ for (unsigned i = 1; i < N - 1; ++i) {
+ const SCEV *NewStepSCEV = SE->getMinusSCEV(SE->getSCEV(DRS.Roots[i]),
+ SE->getSCEV(DRS.Roots[i-1]));
+ if (NewStepSCEV != StepSCEV)
+ return false;
+ }
+
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56812.186366.patch
Type: text/x-patch
Size: 2139 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190212/db1dc261/attachment.bin>
More information about the llvm-commits
mailing list