summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-11-27 00:38:03 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-11-27 00:38:03 +0000
commit2e38cf961d6d80c88290ca6b8d867e021f80b763 (patch)
treed2b0eb5f21c74132c1217d3717dab0d1062994a7 /test
parent9fbf6173b8730e18b39c0a6f3f348451f506780e (diff)
downloadllvm-2e38cf961d6d80c88290ca6b8d867e021f80b763.tar.gz
llvm-2e38cf961d6d80c88290ca6b8d867e021f80b763.tar.bz2
llvm-2e38cf961d6d80c88290ca6b8d867e021f80b763.tar.xz
Introduce a loop block rotation optimization to the new block placement
pass. This is designed to achieve one of the important optimizations that the old code placement pass did, but more simply. This is a somewhat rough and *very* conservative version of the transform. We could get a lot fancier here if there are profitable cases to do so. In particular, this only looks for a single pattern, it insists that the loop backedge being rotated away is the last backedge in the chain, and it doesn't provide any means of doing better in-loop placement due to the rotation. However, it appears that it will handle the important loops I am finding in the LLVM test suite. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145158 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CodeGen/X86/block-placement.ll30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/CodeGen/X86/block-placement.ll b/test/CodeGen/X86/block-placement.ll
index f87d1a6daf..d0afee6ada 100644
--- a/test/CodeGen/X86/block-placement.ll
+++ b/test/CodeGen/X86/block-placement.ll
@@ -169,6 +169,36 @@ exit:
ret i32 %sum
}
+define i32 @test_loop_rotate(i32 %i, i32* %a) {
+; Check that we rotate conditional exits from the loop to the bottom of the
+; loop, eliminating unconditional branches to the top.
+; CHECK: test_loop_rotate:
+; CHECK: %entry
+; CHECK: %body1
+; CHECK: %body0
+; CHECK: %exit
+
+entry:
+ br label %body0
+
+body0:
+ %iv = phi i32 [ 0, %entry ], [ %next, %body1 ]
+ %base = phi i32 [ 0, %entry ], [ %sum, %body1 ]
+ %next = add i32 %iv, 1
+ %exitcond = icmp eq i32 %next, %i
+ br i1 %exitcond, label %exit, label %body1
+
+body1:
+ %arrayidx = getelementptr inbounds i32* %a, i32 %iv
+ %0 = load i32* %arrayidx
+ %sum = add nsw i32 %0, %base
+ %bailcond1 = icmp eq i32 %sum, 42
+ br label %body0
+
+exit:
+ ret i32 %base
+}
+
define i32 @test_loop_align(i32 %i, i32* %a) {
; Check that we provide basic loop body alignment with the block placement
; pass.