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 ;; should not turn into <1 x i64> - It is a banned MMX datatype.
92 define i64 @test6(<2 x float> %X) {
93 %X_addr = alloca <2 x float>
94 store <2 x float> %X, <2 x float>* %X_addr
95 %P = bitcast <2 x float>* %X_addr to i64*
99 ; CHECK-NEXT: bitcast <2 x float> %X to i64
100 ; CHECK-NEXT: ret i64