1; RUN: opt < %s -scalarrepl -instcombine | \
2; RUN:   llc -march=x86 -mcpu=yonah | not grep sub.*esp
3
4; This checks that various insert/extract idiom work without going to the
5; stack.
6target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
7
8define void @test(<4 x float>* %F, float %f) {
9entry:
10	%tmp = load <4 x float>* %F		; <<4 x float>> [#uses=2]
11	%tmp3 = fadd <4 x float> %tmp, %tmp		; <<4 x float>> [#uses=1]
12	%tmp10 = insertelement <4 x float> %tmp3, float %f, i32 0		; <<4 x float>> [#uses=2]
13	%tmp6 = fadd <4 x float> %tmp10, %tmp10		; <<4 x float>> [#uses=1]
14	store <4 x float> %tmp6, <4 x float>* %F
15	ret void
16}
17
18define void @test2(<4 x float>* %F, float %f) {
19entry:
20	%G = alloca <4 x float>, align 16		; <<4 x float>*> [#uses=3]
21	%tmp = load <4 x float>* %F		; <<4 x float>> [#uses=2]
22	%tmp3 = fadd <4 x float> %tmp, %tmp		; <<4 x float>> [#uses=1]
23	store <4 x float> %tmp3, <4 x float>* %G
24	%tmp.upgrd.1 = getelementptr <4 x float>* %G, i32 0, i32 2		; <float*> [#uses=1]
25	store float %f, float* %tmp.upgrd.1
26	%tmp4 = load <4 x float>* %G		; <<4 x float>> [#uses=2]
27	%tmp6 = fadd <4 x float> %tmp4, %tmp4		; <<4 x float>> [#uses=1]
28	store <4 x float> %tmp6, <4 x float>* %F
29	ret void
30}
31
32define void @test3(<4 x float>* %F, float* %f) {
33entry:
34	%G = alloca <4 x float>, align 16		; <<4 x float>*> [#uses=2]
35	%tmp = load <4 x float>* %F		; <<4 x float>> [#uses=2]
36	%tmp3 = fadd <4 x float> %tmp, %tmp		; <<4 x float>> [#uses=1]
37	store <4 x float> %tmp3, <4 x float>* %G
38	%tmp.upgrd.2 = getelementptr <4 x float>* %G, i32 0, i32 2		; <float*> [#uses=1]
39	%tmp.upgrd.3 = load float* %tmp.upgrd.2		; <float> [#uses=1]
40	store float %tmp.upgrd.3, float* %f
41	ret void
42}
43
44define void @test4(<4 x float>* %F, float* %f) {
45entry:
46	%tmp = load <4 x float>* %F		; <<4 x float>> [#uses=2]
47	%tmp5.lhs = extractelement <4 x float> %tmp, i32 0		; <float> [#uses=1]
48	%tmp5.rhs = extractelement <4 x float> %tmp, i32 0		; <float> [#uses=1]
49	%tmp5 = fadd float %tmp5.lhs, %tmp5.rhs		; <float> [#uses=1]
50	store float %tmp5, float* %f
51	ret void
52}
53