summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorMax Kazantsev <max.kazantsev@azul.com>2018-05-23 10:09:53 +0000
committerMax Kazantsev <max.kazantsev@azul.com>2018-05-23 10:09:53 +0000
commitd99f3bacb4b92847e8fae3be4cab4acbe107df52 (patch)
tree595221b66a878310a0f4d9e76135dcb3ccb74b70 /llvm/test/Transforms
parentc0099f9be7dfddab9a4c496f2c9c58f5aefe8e31 (diff)
downloadbcm5719-llvm-d99f3bacb4b92847e8fae3be4cab4acbe107df52.tar.gz
bcm5719-llvm-d99f3bacb4b92847e8fae3be4cab4acbe107df52.zip
[LoopUnswitch] Fix SCEV invalidation in unswitching
Loop unswitching makes substantial changes to a loop that can also affect cached SCEV info in its outer loops as well, but it only cares to invalidate SCEV cache for the innermost loop in case of full unswitching and does not invalidate anything at all in case of trivial unswitching. As result, we may end up with incorrect data in cache. Differential Revision: https://reviews.llvm.org/D46045 Reviewed By: mzolotukhin llvm-svn: 333072
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/LoopUnswitch/invalidate-scev.ll33
1 files changed, 33 insertions, 0 deletions
diff --git a/llvm/test/Transforms/LoopUnswitch/invalidate-scev.ll b/llvm/test/Transforms/LoopUnswitch/invalidate-scev.ll
new file mode 100644
index 00000000000..f1e9443556a
--- /dev/null
+++ b/llvm/test/Transforms/LoopUnswitch/invalidate-scev.ll
@@ -0,0 +1,33 @@
+; RUN: opt -S -indvars -loop-unswitch < %s | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @test_01() {
+
+; Make sure we don't fail by SCEV's assertion due to incorrect invalidation.
+; CHECK-LABEL: @test_01
+
+entry:
+ br label %loop
+
+loop: ; preds = %backedge, %entry
+ %p_50.addr.0 = phi i16 [ undef, %entry ], [ %add2699, %backedge ]
+ %idxprom2690 = sext i16 %p_50.addr.0 to i32
+ %arrayidx2691 = getelementptr inbounds [5 x i32], [5 x i32]* undef, i32 0, i32 %idxprom2690
+ %0 = load i32, i32* %arrayidx2691, align 1
+ %tobool2692 = icmp ne i32 %0, 0
+ br label %inner_loop
+
+inner_loop: ; preds = %inner_backedge, %loop
+ br i1 %tobool2692, label %backedge, label %inner_backedge
+
+inner_backedge: ; preds = %inner_loop
+ br label %inner_loop
+
+backedge: ; preds = %inner_loop
+ %add2699 = add nsw i16 %p_50.addr.0, 1
+ br i1 false, label %loop, label %exit
+
+exit: ; preds = %backedge
+ unreachable
+}
OpenPOWER on IntegriCloud