Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality...
[oota-llvm.git] / test / Transforms / ScalarRepl / vector_promote.ll
1 ; RUN: opt < %s -scalarrepl -S | FileCheck %s
2 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"
3 target triple = "x86_64-apple-darwin10.0.0"
4
5 define void @test1(<4 x float>* %F, float %f) {
6 entry:
7         %G = alloca <4 x float>, align 16               ; <<4 x float>*> [#uses=3]
8         %tmp = load <4 x float>* %F             ; <<4 x float>> [#uses=2]
9         %tmp3 = fadd <4 x float> %tmp, %tmp             ; <<4 x float>> [#uses=1]
10         store <4 x float> %tmp3, <4 x float>* %G
11         %G.upgrd.1 = getelementptr <4 x float>* %G, i32 0, i32 0                ; <float*> [#uses=1]
12         store float %f, float* %G.upgrd.1
13         %tmp4 = load <4 x float>* %G            ; <<4 x float>> [#uses=2]
14         %tmp6 = fadd <4 x float> %tmp4, %tmp4           ; <<4 x float>> [#uses=1]
15         store <4 x float> %tmp6, <4 x float>* %F
16         ret void
17 ; CHECK-LABEL: @test1(
18 ; CHECK-NOT: alloca
19 ; CHECK: %tmp = load <4 x float>* %F
20 ; CHECK: fadd <4 x float> %tmp, %tmp
21 ; CHECK-NEXT: insertelement <4 x float> %tmp3, float %f, i32 0
22 }
23
24 define void @test2(<4 x float>* %F, float %f) {
25 entry:
26         %G = alloca <4 x float>, align 16               ; <<4 x float>*> [#uses=3]
27         %tmp = load <4 x float>* %F             ; <<4 x float>> [#uses=2]
28         %tmp3 = fadd <4 x float> %tmp, %tmp             ; <<4 x float>> [#uses=1]
29         store <4 x float> %tmp3, <4 x float>* %G
30         %tmp.upgrd.2 = getelementptr <4 x float>* %G, i32 0, i32 2              ; <float*> [#uses=1]
31         store float %f, float* %tmp.upgrd.2
32         %tmp4 = load <4 x float>* %G            ; <<4 x float>> [#uses=2]
33         %tmp6 = fadd <4 x float> %tmp4, %tmp4           ; <<4 x float>> [#uses=1]
34         store <4 x float> %tmp6, <4 x float>* %F
35         ret void
36 ; CHECK-LABEL: @test2(
37 ; CHECK-NOT: alloca
38 ; CHECK: %tmp = load <4 x float>* %F
39 ; CHECK: fadd <4 x float> %tmp, %tmp
40 ; CHECK-NEXT: insertelement <4 x float> %tmp3, float %f, i32 2
41 }
42
43 define void @test3(<4 x float>* %F, float* %f) {
44 entry:
45         %G = alloca <4 x float>, align 16               ; <<4 x float>*> [#uses=2]
46         %tmp = load <4 x float>* %F             ; <<4 x float>> [#uses=2]
47         %tmp3 = fadd <4 x float> %tmp, %tmp             ; <<4 x float>> [#uses=1]
48         store <4 x float> %tmp3, <4 x float>* %G
49         %tmp.upgrd.3 = getelementptr <4 x float>* %G, i32 0, i32 2              ; <float*> [#uses=1]
50         %tmp.upgrd.4 = load float* %tmp.upgrd.3         ; <float> [#uses=1]
51         store float %tmp.upgrd.4, float* %f
52         ret void
53 ; CHECK-LABEL: @test3(
54 ; CHECK-NOT: alloca
55 ; CHECK: %tmp = load <4 x float>* %F
56 ; CHECK: fadd <4 x float> %tmp, %tmp
57 ; CHECK-NEXT: extractelement <4 x float> %tmp3, i32 2
58 }
59
60 define void @test4(<4 x float>* %F, float* %f) {
61 entry:
62         %G = alloca <4 x float>, align 16               ; <<4 x float>*> [#uses=2]
63         %tmp = load <4 x float>* %F             ; <<4 x float>> [#uses=2]
64         %tmp3 = fadd <4 x float> %tmp, %tmp             ; <<4 x float>> [#uses=1]
65         store <4 x float> %tmp3, <4 x float>* %G
66         %G.upgrd.5 = getelementptr <4 x float>* %G, i32 0, i32 0                ; <float*> [#uses=1]
67         %tmp.upgrd.6 = load float* %G.upgrd.5           ; <float> [#uses=1]
68         store float %tmp.upgrd.6, float* %f
69         ret void
70 ; CHECK-LABEL: @test4(
71 ; CHECK-NOT: alloca
72 ; CHECK: %tmp = load <4 x float>* %F
73 ; CHECK: fadd <4 x float> %tmp, %tmp
74 ; CHECK-NEXT: extractelement <4 x float> %tmp3, i32 0
75 }
76
77 define i32 @test5(float %X) {  ;; should turn into bitcast.
78         %X_addr = alloca [4 x float]
79         %X1 = getelementptr [4 x float]* %X_addr, i32 0, i32 2
80         store float %X, float* %X1
81         %a = bitcast float* %X1 to i32*
82         %tmp = load i32* %a
83         ret i32 %tmp
84 ; CHECK-LABEL: @test5(
85 ; CHECK-NEXT: bitcast float %X to i32
86 ; CHECK-NEXT: ret i32
87 }
88
89 define i64 @test6(<2 x float> %X) {
90         %X_addr = alloca <2 x float>
91         store <2 x float> %X, <2 x float>* %X_addr
92         %P = bitcast <2 x float>* %X_addr to i64*
93         %tmp = load i64* %P
94         ret i64 %tmp
95 ; CHECK-LABEL: @test6(
96 ; CHECK: bitcast <2 x float> %X to i64
97 ; CHECK: ret i64
98 }
99
100 %struct.test7 = type { [6 x i32] }
101
102 define void @test7() {
103 entry:
104   %memtmp = alloca %struct.test7, align 16
105   %0 = bitcast %struct.test7* %memtmp to <4 x i32>*
106   store <4 x i32> zeroinitializer, <4 x i32>* %0, align 16
107   %1 = getelementptr inbounds %struct.test7* %memtmp, i64 0, i32 0, i64 5
108   store i32 0, i32* %1, align 4
109   ret void
110 ; CHECK-LABEL: @test7(
111 ; CHECK-NOT: alloca
112 ; CHECK: and i192
113 }
114
115 ; When promoting an alloca to a 1-element vector type, instructions that
116 ; produce that same vector type should not be changed to insert one element
117 ; into a new vector. <rdar://problem/14249078>
118 define <1 x i64> @test8(<1 x i64> %a) {
119 entry:
120   %a.addr = alloca <1 x i64>, align 8
121   %__a = alloca <1 x i64>, align 8
122   %tmp = alloca <1 x i64>, align 8
123   store <1 x i64> %a, <1 x i64>* %a.addr, align 8
124   %0 = load <1 x i64>* %a.addr, align 8
125   store <1 x i64> %0, <1 x i64>* %__a, align 8
126   %1 = load <1 x i64>* %__a, align 8
127   %2 = bitcast <1 x i64> %1 to <8 x i8>
128   %3 = bitcast <8 x i8> %2 to <1 x i64>
129   %vshl_n = shl <1 x i64> %3, <i64 4>
130   store <1 x i64> %vshl_n, <1 x i64>* %tmp
131   %4 = load <1 x i64>* %tmp
132   ret <1 x i64> %4
133 ; CHECK-LABEL: @test8(
134 ; CHECK-NOT: alloca
135 ; CHECK-NOT: insertelement
136 ; CHECK: ret <1 x i64>
137 }