1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2 ; RUN: llc < %s -mtriple=x86_64-apple-macosx -mattr=+sse2 -mcpu=nehalem | FileCheck %s 3 4 ; rdar: 12558838 5 ; PR14221 6 ; There is a mismatch between the intrinsic and the actual instruction. 7 ; The actual instruction has a partial update of dest, while the intrinsic 8 ; passes through the upper FP values. Here, we make sure the source and 9 ; destination of each scalar unary op are the same. 10 11 define void @rsqrtss(<4 x float> %a) nounwind uwtable ssp { 12 ; CHECK-LABEL: rsqrtss: 13 ; CHECK: ## BB#0: ## %entry 14 ; CHECK-NEXT: rsqrtss %xmm0, %xmm0 15 ; CHECK-NEXT: cvtss2sd %xmm0, %xmm2 16 ; CHECK-NEXT: movshdup {{.*#+}} xmm0 = xmm0[1,1,3,3] 17 ; CHECK-NEXT: cvtss2sd %xmm0, %xmm1 18 ; CHECK-NEXT: movaps %xmm2, %xmm0 19 ; CHECK-NEXT: jmp _callee ## TAILCALL 20 entry: 21 22 %0 = tail call <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float> %a) nounwind 23 %a.addr.0.extract = extractelement <4 x float> %0, i32 0 24 %conv = fpext float %a.addr.0.extract to double 25 %a.addr.4.extract = extractelement <4 x float> %0, i32 1 26 %conv3 = fpext float %a.addr.4.extract to double 27 tail call void @callee(double %conv, double %conv3) nounwind 28 ret void 29 } 30 declare void @callee(double, double) 31 declare <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float>) nounwind readnone 32 33 define void @rcpss(<4 x float> %a) nounwind uwtable ssp { 34 ; CHECK-LABEL: rcpss: 35 ; CHECK: ## BB#0: ## %entry 36 ; CHECK-NEXT: rcpss %xmm0, %xmm0 37 ; CHECK-NEXT: cvtss2sd %xmm0, %xmm2 38 ; CHECK-NEXT: movshdup {{.*#+}} xmm0 = xmm0[1,1,3,3] 39 ; CHECK-NEXT: cvtss2sd %xmm0, %xmm1 40 ; CHECK-NEXT: movaps %xmm2, %xmm0 41 ; CHECK-NEXT: jmp _callee ## TAILCALL 42 entry: 43 44 %0 = tail call <4 x float> @llvm.x86.sse.rcp.ss(<4 x float> %a) nounwind 45 %a.addr.0.extract = extractelement <4 x float> %0, i32 0 46 %conv = fpext float %a.addr.0.extract to double 47 %a.addr.4.extract = extractelement <4 x float> %0, i32 1 48 %conv3 = fpext float %a.addr.4.extract to double 49 tail call void @callee(double %conv, double %conv3) nounwind 50 ret void 51 } 52 declare <4 x float> @llvm.x86.sse.rcp.ss(<4 x float>) nounwind readnone 53 54 define void @sqrtss(<4 x float> %a) nounwind uwtable ssp { 55 ; CHECK-LABEL: sqrtss: 56 ; CHECK: ## BB#0: ## %entry 57 ; CHECK-NEXT: sqrtss %xmm0, %xmm0 58 ; CHECK-NEXT: cvtss2sd %xmm0, %xmm2 59 ; CHECK-NEXT: movshdup {{.*#+}} xmm0 = xmm0[1,1,3,3] 60 ; CHECK-NEXT: cvtss2sd %xmm0, %xmm1 61 ; CHECK-NEXT: movaps %xmm2, %xmm0 62 ; CHECK-NEXT: jmp _callee ## TAILCALL 63 entry: 64 65 %0 = tail call <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float> %a) nounwind 66 %a.addr.0.extract = extractelement <4 x float> %0, i32 0 67 %conv = fpext float %a.addr.0.extract to double 68 %a.addr.4.extract = extractelement <4 x float> %0, i32 1 69 %conv3 = fpext float %a.addr.4.extract to double 70 tail call void @callee(double %conv, double %conv3) nounwind 71 ret void 72 } 73 declare <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float>) nounwind readnone 74 75 define void @sqrtsd(<2 x double> %a) nounwind uwtable ssp { 76 ; CHECK-LABEL: sqrtsd: 77 ; CHECK: ## BB#0: ## %entry 78 ; CHECK-NEXT: sqrtsd %xmm0, %xmm0 79 ; CHECK-NEXT: cvtsd2ss %xmm0, %xmm2 80 ; CHECK-NEXT: shufpd {{.*#+}} xmm0 = xmm0[1,0] 81 ; CHECK-NEXT: cvtsd2ss %xmm0, %xmm1 82 ; CHECK-NEXT: movaps %xmm2, %xmm0 83 ; CHECK-NEXT: jmp _callee2 ## TAILCALL 84 entry: 85 86 %0 = tail call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %a) nounwind 87 %a0 = extractelement <2 x double> %0, i32 0 88 %conv = fptrunc double %a0 to float 89 %a1 = extractelement <2 x double> %0, i32 1 90 %conv3 = fptrunc double %a1 to float 91 tail call void @callee2(float %conv, float %conv3) nounwind 92 ret void 93 } 94 95 declare void @callee2(float, float) 96 declare <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double>) nounwind readnone 97 98 define <2 x double> @load_fold_cvtss2sd_int(<4 x float> *%a) { 99 ; CHECK-LABEL: load_fold_cvtss2sd_int: 100 ; CHECK: ## BB#0: 101 ; CHECK-NEXT: movaps (%rdi), %xmm1 102 ; CHECK-NEXT: xorps %xmm0, %xmm0 103 ; CHECK-NEXT: cvtss2sd %xmm1, %xmm0 104 ; CHECK-NEXT: retq 105 %ld = load <4 x float>, <4 x float> *%a 106 %x = call <2 x double> @llvm.x86.sse2.cvtss2sd(<2 x double> <double 0x0, double 0x0>, <4 x float> %ld) 107 ret <2 x double> %x 108 } 109 110 define <2 x double> @load_fold_cvtss2sd_int_optsize(<4 x float> *%a) optsize { 111 ; CHECK-LABEL: load_fold_cvtss2sd_int_optsize: 112 ; CHECK: ## BB#0: 113 ; CHECK-NEXT: xorps %xmm0, %xmm0 114 ; CHECK-NEXT: cvtss2sd (%rdi), %xmm0 115 ; CHECK-NEXT: retq 116 %ld = load <4 x float>, <4 x float> *%a 117 %x = call <2 x double> @llvm.x86.sse2.cvtss2sd(<2 x double> <double 0x0, double 0x0>, <4 x float> %ld) 118 ret <2 x double> %x 119 } 120 121 define <2 x double> @load_fold_cvtss2sd_int_minsize(<4 x float> *%a) minsize { 122 ; CHECK-LABEL: load_fold_cvtss2sd_int_minsize: 123 ; CHECK: ## BB#0: 124 ; CHECK-NEXT: xorps %xmm0, %xmm0 125 ; CHECK-NEXT: cvtss2sd (%rdi), %xmm0 126 ; CHECK-NEXT: retq 127 %ld = load <4 x float>, <4 x float> *%a 128 %x = call <2 x double> @llvm.x86.sse2.cvtss2sd(<2 x double> <double 0x0, double 0x0>, <4 x float> %ld) 129 ret <2 x double> %x 130 } 131 132 declare <2 x double> @llvm.x86.sse2.cvtss2sd(<2 x double>, <4 x float>) nounwind readnone 133 134