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