1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: llc < %s -mtriple=i686-apple-darwin9 -mattr=+sse,+sse2,+sse4.1 | FileCheck %s
3
4target datalayout = "e-p:32:32"
5
6define i16 @test1(float %f) nounwind {
7; CHECK-LABEL: test1:
8; CHECK:       ## BB#0:
9; CHECK-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
10; CHECK-NEXT:    xorps %xmm1, %xmm1
11; CHECK-NEXT:    subss LCPI0_0, %xmm0
12; CHECK-NEXT:    mulss LCPI0_1, %xmm0
13; CHECK-NEXT:    minss LCPI0_2, %xmm0
14; CHECK-NEXT:    maxss %xmm1, %xmm0
15; CHECK-NEXT:    cvttss2si %xmm0, %eax
16; CHECK-NEXT:    ## kill: %AX<def> %AX<kill> %EAX<kill>
17; CHECK-NEXT:    retl
18;
19  %tmp = insertelement <4 x float> undef, float %f, i32 0		; <<4 x float>> [#uses=1]
20  %tmp10 = insertelement <4 x float> %tmp, float 0.000000e+00, i32 1		; <<4 x float>> [#uses=1]
21  %tmp11 = insertelement <4 x float> %tmp10, float 0.000000e+00, i32 2		; <<4 x float>> [#uses=1]
22  %tmp12 = insertelement <4 x float> %tmp11, float 0.000000e+00, i32 3		; <<4 x float>> [#uses=1]
23  %tmp28 = tail call <4 x float> @llvm.x86.sse.sub.ss( <4 x float> %tmp12, <4 x float> < float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00 > )		; <<4 x float>> [#uses=1]
24  %tmp37 = tail call <4 x float> @llvm.x86.sse.mul.ss( <4 x float> %tmp28, <4 x float> < float 5.000000e-01, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00 > )		; <<4 x float>> [#uses=1]
25  %tmp48 = tail call <4 x float> @llvm.x86.sse.min.ss( <4 x float> %tmp37, <4 x float> < float 6.553500e+04, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00 > )		; <<4 x float>> [#uses=1]
26  %tmp59 = tail call <4 x float> @llvm.x86.sse.max.ss( <4 x float> %tmp48, <4 x float> zeroinitializer )		; <<4 x float>> [#uses=1]
27  %tmp.upgrd.1 = tail call i32 @llvm.x86.sse.cvttss2si( <4 x float> %tmp59 )		; <i32> [#uses=1]
28  %tmp69 = trunc i32 %tmp.upgrd.1 to i16		; <i16> [#uses=1]
29  ret i16 %tmp69
30}
31
32define i16 @test2(float %f) nounwind {
33; CHECK-LABEL: test2:
34; CHECK:       ## BB#0:
35; CHECK-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
36; CHECK-NEXT:    addss LCPI1_0, %xmm0
37; CHECK-NEXT:    mulss LCPI1_1, %xmm0
38; CHECK-NEXT:    minss LCPI1_2, %xmm0
39; CHECK-NEXT:    xorps %xmm1, %xmm1
40; CHECK-NEXT:    maxss %xmm1, %xmm0
41; CHECK-NEXT:    cvttss2si %xmm0, %eax
42; CHECK-NEXT:    ## kill: %AX<def> %AX<kill> %EAX<kill>
43; CHECK-NEXT:    retl
44;
45  %tmp28 = fsub float %f, 1.000000e+00		; <float> [#uses=1]
46  %tmp37 = fmul float %tmp28, 5.000000e-01		; <float> [#uses=1]
47  %tmp375 = insertelement <4 x float> undef, float %tmp37, i32 0		; <<4 x float>> [#uses=1]
48  %tmp48 = tail call <4 x float> @llvm.x86.sse.min.ss( <4 x float> %tmp375, <4 x float> < float 6.553500e+04, float undef, float undef, float undef > )		; <<4 x float>> [#uses=1]
49  %tmp59 = tail call <4 x float> @llvm.x86.sse.max.ss( <4 x float> %tmp48, <4 x float> < float 0.000000e+00, float undef, float undef, float undef > )		; <<4 x float>> [#uses=1]
50  %tmp = tail call i32 @llvm.x86.sse.cvttss2si( <4 x float> %tmp59 )		; <i32> [#uses=1]
51  %tmp69 = trunc i32 %tmp to i16		; <i16> [#uses=1]
52  ret i16 %tmp69
53}
54
55declare <4 x float> @llvm.x86.sse.sub.ss(<4 x float>, <4 x float>)
56
57declare <4 x float> @llvm.x86.sse.mul.ss(<4 x float>, <4 x float>)
58
59declare <4 x float> @llvm.x86.sse.min.ss(<4 x float>, <4 x float>)
60
61declare <4 x float> @llvm.x86.sse.max.ss(<4 x float>, <4 x float>)
62
63declare i32 @llvm.x86.sse.cvttss2si(<4 x float>)
64
65declare <4 x float> @llvm.x86.sse41.round.ss(<4 x float>, <4 x float>, i32)
66
67declare <4 x float> @f()
68
69define <4 x float> @test3(<4 x float> %A, float *%b, i32 %C) nounwind {
70; CHECK-LABEL: test3:
71; CHECK:       ## BB#0:
72; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
73; CHECK-NEXT:    roundss $4, (%eax), %xmm0
74; CHECK-NEXT:    retl
75;
76  %a = load float , float *%b
77  %B = insertelement <4 x float> undef, float %a, i32 0
78  %X = call <4 x float> @llvm.x86.sse41.round.ss(<4 x float> %A, <4 x float> %B, i32 4)
79  ret <4 x float> %X
80}
81
82define <4 x float> @test4(<4 x float> %A, float *%b, i32 %C) nounwind {
83; CHECK-LABEL: test4:
84; CHECK:       ## BB#0:
85; CHECK-NEXT:    subl $28, %esp
86; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
87; CHECK-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
88; CHECK-NEXT:    movaps %xmm0, (%esp) ## 16-byte Spill
89; CHECK-NEXT:    calll _f
90; CHECK-NEXT:    movaps (%esp), %xmm1 ## 16-byte Reload
91; CHECK-NEXT:    roundss $4, %xmm1, %xmm0
92; CHECK-NEXT:    addl $28, %esp
93; CHECK-NEXT:    retl
94;
95  %a = load float , float *%b
96  %B = insertelement <4 x float> undef, float %a, i32 0
97  %q = call <4 x float> @f()
98  %X = call <4 x float> @llvm.x86.sse41.round.ss(<4 x float> %q, <4 x float> %B, i32 4)
99  ret <4 x float> %X
100}
101
102; PR13576
103define  <2 x double> @test5() nounwind uwtable readnone noinline {
104; CHECK-LABEL: test5:
105; CHECK:       ## BB#0: ## %entry
106; CHECK-NEXT:    movaps {{.*#+}} xmm0 = [4.569870e+02,1.233210e+02]
107; CHECK-NEXT:    movl $128, %eax
108; CHECK-NEXT:    cvtsi2sdl %eax, %xmm0
109; CHECK-NEXT:    retl
110;
111entry:
112  %0 = tail call <2 x double> @llvm.x86.sse2.cvtsi2sd(<2 x double> <double
1134.569870e+02, double 1.233210e+02>, i32 128) nounwind readnone
114  ret <2 x double> %0
115}
116
117declare <2 x double> @llvm.x86.sse2.cvtsi2sd(<2 x double>, i32) nounwind readnone
118