aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/ScalarRepl/phi-select.ll
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-01-24 01:07:11 +0000
committerChris Lattner <sabre@nondot.org>2011-01-24 01:07:11 +0000
commite3357863aaabe297c5fa819d083f2308ebb5f2c2 (patch)
treed9e67adfec74e5a2600746fab7b0a9c9e53cf7b5 /test/Transforms/ScalarRepl/phi-select.ll
parentc87c50a39c1bc27437352feee0f6aba2d50fa1b5 (diff)
downloadexternal_llvm-e3357863aaabe297c5fa819d083f2308ebb5f2c2.zip
external_llvm-e3357863aaabe297c5fa819d083f2308ebb5f2c2.tar.gz
external_llvm-e3357863aaabe297c5fa819d083f2308ebb5f2c2.tar.bz2
enhance SRoA to promote allocas that are used by PHI nodes. This often
occurs because instcombine sinks loads and inserts phis. This kicks in on such apps as 175.vpr, eon, 403.gcc, xalancbmk and a bunch of times in spec2006 in some app that uses std::deque. This resolves the last of rdar://7339113. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124090 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/ScalarRepl/phi-select.ll')
-rw-r--r--test/Transforms/ScalarRepl/phi-select.ll27
1 files changed, 24 insertions, 3 deletions
diff --git a/test/Transforms/ScalarRepl/phi-select.ll b/test/Transforms/ScalarRepl/phi-select.ll
index f612ed5..fa3972d 100644
--- a/test/Transforms/ScalarRepl/phi-select.ll
+++ b/test/Transforms/ScalarRepl/phi-select.ll
@@ -25,8 +25,8 @@ entry:
}
; CHECK: @test2
-; CHECK: %A.0 = alloca i32
-; CHECK: %A.1 = alloca i32
+; CHECK: %X.ld = phi i32 [ 1, %entry ], [ 2, %T ]
+; CHECK-NEXT: ret i32 %X.ld
define i32 @test2(i1 %c) {
entry:
%A = alloca {i32, i32}
@@ -35,7 +35,7 @@ entry:
br i1 %c, label %T, label %F
T:
%C = getelementptr {i32, i32}* %A, i32 0, i32 1
- store i32 2, i32* %B
+ store i32 2, i32* %C
br label %F
F:
%X = phi i32* [%B, %entry], [%C, %T]
@@ -130,3 +130,24 @@ define i32 @test7(i32 %x, i1 %c) nounwind readnone ssp {
; CHECK: ret i32 %r
}
+;; Promote allocs that are PHI'd together by moving the loads.
+define i32 @test8(i32 %x) nounwind readnone ssp {
+; CHECK: @test8
+; CHECK-NOT: load i32
+; CHECK-NOT: store i32
+; CHECK: %p.0.ld = phi i32 [ 2, %entry ], [ 1, %T ]
+; CHECK-NEXT: ret i32 %p.0.ld
+entry:
+ %a = alloca i32, align 8
+ %b = alloca i32, align 8
+ store i32 1, i32* %a, align 8
+ store i32 2, i32* %b, align 8
+ %c = icmp eq i32 %x, 0
+ br i1 %c, label %T, label %Cont
+T:
+ br label %Cont
+Cont:
+ %p.0 = phi i32* [%b, %entry],[%a, %T]
+ %r = load i32* %p.0, align 8
+ ret i32 %r
+}