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"
5 define void @test1(<4 x float>* %F, float %f) {
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
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
24 define void @test2(<4 x float>* %F, float %f) {
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
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
43 define void @test3(<4 x float>* %F, float* %f) {
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
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
60 define void @test4(<4 x float>* %F, float* %f) {
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
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
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*
85 ; CHECK-NEXT: bitcast float %X to i32
90 define i64 @test6(<2 x float> %X) {
91 %X_addr = alloca <2 x float>
92 store <2 x float> %X, <2 x float>* %X_addr
93 %P = bitcast <2 x float>* %X_addr to i64*
97 ; CHECK: bitcast <2 x float> %X to i64
101 define float @test7(<4 x float> %x) {
102 %a = alloca <4 x float>
103 store <4 x float> %x, <4 x float>* %a
104 %p = bitcast <4 x float>* %a to <2 x float>*
105 %b = load <2 x float>* %p
106 %q = getelementptr <4 x float>* %a, i32 0, i32 2
111 ; CHECK: bitcast <4 x float> %x to <2 x double>
112 ; CHECK-NEXT: extractelement <2 x double>
113 ; CHECK-NEXT: bitcast double %tmp4 to <2 x float>
114 ; CHECK-NEXT: extractelement <4 x float>
117 define void @test8(<4 x float> %x, <2 x float> %y) {
118 %a = alloca <4 x float>
119 store <4 x float> %x, <4 x float>* %a
120 %p = bitcast <4 x float>* %a to <2 x float>*
121 store <2 x float> %y, <2 x float>* %p
125 ; CHECK: bitcast <4 x float> %x to <2 x double>
126 ; CHECK-NEXT: bitcast <2 x float> %y to double
127 ; CHECK-NEXT: insertelement <2 x double>
128 ; CHECK-NEXT: bitcast <2 x double> %tmp2 to <4 x float>
131 define i256 @test9(<4 x i256> %x) {
132 %a = alloca <4 x i256>
133 store <4 x i256> %x, <4 x i256>* %a
134 %p = bitcast <4 x i256>* %a to <2 x i256>*
135 %b = load <2 x i256>* %p
136 %q = getelementptr <4 x i256>* %a, i32 0, i32 2
141 ; CHECK: bitcast <4 x i256> %x to <2 x i512>
142 ; CHECK-NEXT: extractelement <2 x i512>
143 ; CHECK-NEXT: bitcast i512 %tmp4 to <2 x i256>
144 ; CHECK-NEXT: extractelement <4 x i256>
147 define void @test10(<4 x i256> %x, <2 x i256> %y) {
148 %a = alloca <4 x i256>
149 store <4 x i256> %x, <4 x i256>* %a
150 %p = bitcast <4 x i256>* %a to <2 x i256>*
151 store <2 x i256> %y, <2 x i256>* %p
155 ; CHECK: bitcast <4 x i256> %x to <2 x i512>
156 ; CHECK-NEXT: bitcast <2 x i256> %y to i512
157 ; CHECK-NEXT: insertelement <2 x i512>
158 ; CHECK-NEXT: bitcast <2 x i512> %tmp2 to <4 x i256>
161 %union.v = type { <2 x i64> }
163 define void @test11(<2 x i64> %x) {
165 %p = getelementptr inbounds %union.v* %a, i32 0, i32 0
166 store <2 x i64> %x, <2 x i64>* %p, align 16
167 %q = getelementptr inbounds %union.v* %a, i32 0, i32 0
168 %r = bitcast <2 x i64>* %q to <4 x float>*
169 %b = load <4 x float>* %r, align 16
175 define void @test12() {
177 %a = alloca <64 x i8>, align 64
178 store <64 x i8> undef, <64 x i8>* %a, align 64
179 %p = bitcast <64 x i8>* %a to <16 x i8>*
180 %0 = load <16 x i8>* %p, align 64
181 store <16 x i8> undef, <16 x i8>* %p, align 64
182 %q = bitcast <16 x i8>* %p to <64 x i8>*
183 %1 = load <64 x i8>* %q, align 64
187 ; CHECK: extractelement <4 x i128>
188 ; CHECK: insertelement <4 x i128>
191 define float @test13(<4 x float> %x, <2 x i32> %y) {
192 %a = alloca <4 x float>
193 store <4 x float> %x, <4 x float>* %a
194 %p = bitcast <4 x float>* %a to <2 x float>*
195 %b = load <2 x float>* %p
196 %q = getelementptr <4 x float>* %a, i32 0, i32 2
198 %r = bitcast <4 x float>* %a to <2 x i32>*
199 store <2 x i32> %y, <2 x i32>* %r
203 ; CHECK: bitcast <4 x float> %x to i128