summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/LoopDeletion/update-scev.ll
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2016-05-03 17:50:02 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2016-05-03 17:50:02 +0000
commit905fc27ebf9ec5a262dc320bb66e68f17d597248 (patch)
treed9ef19b195df25f735bc90385bee9b428f8c85e5 /llvm/test/Transforms/LoopDeletion/update-scev.ll
parent013a4ac4aa5da577fff807c44846eb6cfd6d32f4 (diff)
downloadbcm5719-llvm-905fc27ebf9ec5a262dc320bb66e68f17d597248.tar.gz
bcm5719-llvm-905fc27ebf9ec5a262dc320bb66e68f17d597248.zip
[LoopDeletion] Clear SCEV loop dispositions
`Loop::makeLoopInvariant` can hoist instructions out of loops, so loop dispositions for the loop it operated on may need to be cleared. We can be smarter here (especially around how `forgetLoopDispositions` is implemented), but let's be correct first. Fixes PR27570. llvm-svn: 268406
Diffstat (limited to 'llvm/test/Transforms/LoopDeletion/update-scev.ll')
-rw-r--r--llvm/test/Transforms/LoopDeletion/update-scev.ll56
1 files changed, 56 insertions, 0 deletions
diff --git a/llvm/test/Transforms/LoopDeletion/update-scev.ll b/llvm/test/Transforms/LoopDeletion/update-scev.ll
new file mode 100644
index 00000000000..641ba55ed8f
--- /dev/null
+++ b/llvm/test/Transforms/LoopDeletion/update-scev.ll
@@ -0,0 +1,56 @@
+; RUN: opt -S -analyze -scalar-evolution -loop-deletion -scalar-evolution < %s | FileCheck %s --check-prefix=SCEV-EXPRS
+; RUN: opt -S -loop-deletion < %s | FileCheck %s --check-prefix=IR-AFTER-TRANSFORM
+; RUN: opt -S -indvars -loop-deletion -indvars < %s | FileCheck %s --check-prefix=ORIGINAL-CRASH
+
+; Checking for a crash. Loop-deletion would change the loop
+; disposition of an instruction, but not update SCEV.
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.11.0"
+
+define void @pr27570() {
+; IR-AFTER-TRANSFORM-LABEL: @pr27570(
+; ORIGINAL-CRASH: @pr27570(
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.cond14, %entry
+ %f.0 = phi i32 [ 20, %entry ], [ 0, %for.cond14 ]
+ br label %for.body
+
+for.body: ; preds = %for.inc11, %for.cond
+; IR-AFTER-TRANSFORM: for.body:
+; IR-AFTER-TRANSFORM: %cmp = icmp eq i32 %val, -1
+; IR-AFTER-TRANSFORM: %conv7 = zext i1 %cmp to i32
+; IR-AFTER-TRANSFORM: for.body6:
+
+; SCEV-EXPRS: %conv7 = zext i1 %cmp to i32
+; SCEV-EXPRS: %conv7 = zext i1 %cmp to i32
+; SCEV-EXPRS-NEXT: --> {{.*}} LoopDispositions: { %for.body: Variant, %for.cond: Variant, %for.body6: Invariant }
+ %val = phi i32 [ -20, %for.cond ], [ %inc12, %for.inc11 ]
+ %g.040 = phi i32 [ -20, %for.cond ], [ %and.lcssa, %for.inc11 ]
+ br label %for.body6
+
+for.body6: ; preds = %for.body6, %for.body
+ %h.039 = phi i32 [ 1, %for.body ], [ %inc, %for.body6 ]
+ %g.138 = phi i32 [ %g.040, %for.body ], [ %and, %for.body6 ]
+ %cmp = icmp eq i32 %val, -1
+ %conv7 = zext i1 %cmp to i32
+ %add.i = add nsw i32 %conv7, %h.039
+ %sext = shl i32 %add.i, 24
+ %conv8 = ashr exact i32 %sext, 24
+ %cmp9 = icmp eq i32 %conv8, %f.0
+ %conv10 = zext i1 %cmp9 to i32
+ %and = and i32 %conv10, %g.138
+ %inc = add i32 %h.039, 1
+ br i1 undef, label %for.inc11, label %for.body6
+
+for.inc11: ; preds = %for.body6
+ %and.lcssa = phi i32 [ %and, %for.body6 ]
+ %inc12 = add nsw i32 %val, 1
+ %tobool = icmp eq i32 %inc12, 0
+ br i1 %tobool, label %for.cond14, label %for.body
+
+for.cond14: ; preds = %for.cond14, %for.inc11
+ br i1 undef, label %for.cond, label %for.cond14
+}
OpenPOWER on IntegriCloud