summaryrefslogtreecommitdiff
path: root/test/Transforms/LoopRotate
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-02-14 00:00:23 +0000
committerAndrew Trick <atrick@apple.com>2012-02-14 00:00:23 +0000
commitf6629ab84785ff5e7db4cbb9e2d1cbd4ab3b5d34 (patch)
tree8199164f0ff2ee6bb74a2af7339e38b42e330f69 /test/Transforms/LoopRotate
parentc3a825b76cbaea3dcde02e9fa53d8f2d1311fe43 (diff)
downloadllvm-f6629ab84785ff5e7db4cbb9e2d1cbd4ab3b5d34.tar.gz
llvm-f6629ab84785ff5e7db4cbb9e2d1cbd4ab3b5d34.tar.bz2
llvm-f6629ab84785ff5e7db4cbb9e2d1cbd4ab3b5d34.tar.xz
Add simplifyLoopLatch to LoopRotate pass.
This folds a simple loop tail into a loop latch. It covers the common (in fortran) case of postincrement loops. It's a "free" way to expose this type of loop to downstream loop optimizations that bail out on non-canonical loops (getLoopLatch is a heavily used check). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150439 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/LoopRotate')
-rw-r--r--test/Transforms/LoopRotate/simplifylatch.ll39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/Transforms/LoopRotate/simplifylatch.ll b/test/Transforms/LoopRotate/simplifylatch.ll
new file mode 100644
index 0000000000..f4227245f7
--- /dev/null
+++ b/test/Transforms/LoopRotate/simplifylatch.ll
@@ -0,0 +1,39 @@
+; RUN: opt -S < %s -loop-rotate -verify-dom-info -verify-loop-info | FileCheck %s
+; PR2624 unroll multiple exits
+
+@mode_table = global [4 x i32] zeroinitializer ; <[4 x i32]*> [#uses=1]
+
+; CHECK: @f
+; CHECK-NOT: bb4
+define i8 @f() {
+entry:
+ tail call i32 @fegetround( ) ; <i32>:0 [#uses=1]
+ br label %bb
+
+bb: ; preds = %bb4, %entry
+ %mode.0 = phi i8 [ 0, %entry ], [ %indvar.next, %bb4 ] ; <i8> [#uses=4]
+ zext i8 %mode.0 to i32 ; <i32>:1 [#uses=1]
+ getelementptr [4 x i32]* @mode_table, i32 0, i32 %1 ; <i32*>:2 [#uses=1]
+ load i32* %2, align 4 ; <i32>:3 [#uses=1]
+ icmp eq i32 %3, %0 ; <i1>:4 [#uses=1]
+ br i1 %4, label %bb1, label %bb2
+
+bb1: ; preds = %bb
+ ret i8 %mode.0
+
+bb2: ; preds = %bb
+ icmp eq i8 %mode.0, 1 ; <i1>:5 [#uses=1]
+ br i1 %5, label %bb5, label %bb4
+
+bb4: ; preds = %bb2
+ %indvar.next = add i8 %mode.0, 1 ; <i8> [#uses=1]
+ br label %bb
+
+bb5: ; preds = %bb2
+ tail call void @raise_exception( ) noreturn
+ unreachable
+}
+
+declare i32 @fegetround()
+
+declare void @raise_exception() noreturn