2015-11-24 05:33:58 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2015-04-26 04:41:51 +08:00
|
|
|
; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+sse2 < %s | FileCheck %s --check-prefix=SSE
|
|
|
|
; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+avx < %s | FileCheck %s --check-prefix=AVX
|
2017-11-13 13:25:21 +08:00
|
|
|
; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+avx512f < %s | FileCheck %s --check-prefix=AVX
|
2015-02-20 00:59:11 +08:00
|
|
|
|
2015-12-31 17:45:16 +08:00
|
|
|
; Verify we fold loads into unary sse intrinsics only when optimizing for size
|
2015-02-20 00:59:11 +08:00
|
|
|
|
|
|
|
define float @rcpss(float* %a) {
|
2015-04-26 04:41:51 +08:00
|
|
|
; SSE-LABEL: rcpss:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2017-11-13 13:25:21 +08:00
|
|
|
; SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
2015-12-31 17:45:16 +08:00
|
|
|
; SSE-NEXT: rcpss %xmm0, %xmm0
|
2015-04-26 04:41:51 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: rcpss:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2017-11-13 13:25:21 +08:00
|
|
|
; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
2015-12-31 17:45:16 +08:00
|
|
|
; AVX-NEXT: vrcpss %xmm0, %xmm0, %xmm0
|
2015-04-26 04:41:51 +08:00
|
|
|
; AVX-NEXT: retq
|
2015-02-28 05:17:42 +08:00
|
|
|
%ld = load float, float* %a
|
2015-02-20 00:59:11 +08:00
|
|
|
%ins = insertelement <4 x float> undef, float %ld, i32 0
|
|
|
|
%res = tail call <4 x float> @llvm.x86.sse.rcp.ss(<4 x float> %ins)
|
|
|
|
%ext = extractelement <4 x float> %res, i32 0
|
|
|
|
ret float %ext
|
|
|
|
}
|
|
|
|
|
|
|
|
define float @rsqrtss(float* %a) {
|
2015-04-26 04:41:51 +08:00
|
|
|
; SSE-LABEL: rsqrtss:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2017-11-13 13:25:21 +08:00
|
|
|
; SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
2015-12-31 17:45:16 +08:00
|
|
|
; SSE-NEXT: rsqrtss %xmm0, %xmm0
|
2015-04-26 04:41:51 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: rsqrtss:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2017-11-13 13:25:21 +08:00
|
|
|
; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
2015-12-31 17:45:16 +08:00
|
|
|
; AVX-NEXT: vrsqrtss %xmm0, %xmm0, %xmm0
|
2015-04-26 04:41:51 +08:00
|
|
|
; AVX-NEXT: retq
|
2015-02-28 05:17:42 +08:00
|
|
|
%ld = load float, float* %a
|
2015-02-20 00:59:11 +08:00
|
|
|
%ins = insertelement <4 x float> undef, float %ld, i32 0
|
|
|
|
%res = tail call <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float> %ins)
|
|
|
|
%ext = extractelement <4 x float> %res, i32 0
|
|
|
|
ret float %ext
|
|
|
|
}
|
|
|
|
|
|
|
|
define float @sqrtss(float* %a) {
|
2015-04-26 04:41:51 +08:00
|
|
|
; SSE-LABEL: sqrtss:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2017-11-13 13:25:21 +08:00
|
|
|
; SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
2015-12-31 17:45:16 +08:00
|
|
|
; SSE-NEXT: sqrtss %xmm0, %xmm0
|
2015-04-26 04:41:51 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: sqrtss:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2017-11-13 13:25:21 +08:00
|
|
|
; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
2015-12-31 17:45:16 +08:00
|
|
|
; AVX-NEXT: vsqrtss %xmm0, %xmm0, %xmm0
|
2015-04-26 04:41:51 +08:00
|
|
|
; AVX-NEXT: retq
|
2015-02-28 05:17:42 +08:00
|
|
|
%ld = load float, float* %a
|
2015-02-20 00:59:11 +08:00
|
|
|
%ins = insertelement <4 x float> undef, float %ld, i32 0
|
|
|
|
%res = tail call <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float> %ins)
|
|
|
|
%ext = extractelement <4 x float> %res, i32 0
|
|
|
|
ret float %ext
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @sqrtsd(double* %a) {
|
2015-04-26 04:41:51 +08:00
|
|
|
; SSE-LABEL: sqrtsd:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2017-11-13 13:25:21 +08:00
|
|
|
; SSE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
|
2015-12-31 17:45:16 +08:00
|
|
|
; SSE-NEXT: sqrtsd %xmm0, %xmm0
|
2015-04-26 04:41:51 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: sqrtsd:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2017-11-13 13:25:21 +08:00
|
|
|
; AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
|
2015-12-31 17:45:16 +08:00
|
|
|
; AVX-NEXT: vsqrtsd %xmm0, %xmm0, %xmm0
|
2015-04-26 04:41:51 +08:00
|
|
|
; AVX-NEXT: retq
|
2015-02-28 05:17:42 +08:00
|
|
|
%ld = load double, double* %a
|
2015-02-20 00:59:11 +08:00
|
|
|
%ins = insertelement <2 x double> undef, double %ld, i32 0
|
|
|
|
%res = tail call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %ins)
|
|
|
|
%ext = extractelement <2 x double> %res, i32 0
|
|
|
|
ret double %ext
|
|
|
|
}
|
|
|
|
|
2015-12-31 17:45:16 +08:00
|
|
|
define float @rcpss_size(float* %a) optsize {
|
|
|
|
; SSE-LABEL: rcpss_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2015-12-31 17:45:16 +08:00
|
|
|
; SSE-NEXT: rcpss (%rdi), %xmm0
|
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: rcpss_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2015-12-31 17:45:16 +08:00
|
|
|
; AVX-NEXT: vrcpss (%rdi), %xmm0, %xmm0
|
|
|
|
; AVX-NEXT: retq
|
|
|
|
%ld = load float, float* %a
|
|
|
|
%ins = insertelement <4 x float> undef, float %ld, i32 0
|
|
|
|
%res = tail call <4 x float> @llvm.x86.sse.rcp.ss(<4 x float> %ins)
|
|
|
|
%ext = extractelement <4 x float> %res, i32 0
|
|
|
|
ret float %ext
|
|
|
|
}
|
|
|
|
|
2017-11-13 13:25:23 +08:00
|
|
|
define <4 x float> @rcpss_full_size(<4 x float>* %a) optsize {
|
|
|
|
; SSE-LABEL: rcpss_full_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2017-11-13 13:25:24 +08:00
|
|
|
; SSE-NEXT: rcpss (%rdi), %xmm0
|
2017-11-13 13:25:23 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: rcpss_full_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2017-11-13 13:25:24 +08:00
|
|
|
; AVX-NEXT: vrcpss (%rdi), %xmm0, %xmm0
|
2017-11-13 13:25:23 +08:00
|
|
|
; AVX-NEXT: retq
|
|
|
|
%ld = load <4 x float>, <4 x float>* %a
|
|
|
|
%res = tail call <4 x float> @llvm.x86.sse.rcp.ss(<4 x float> %ld)
|
|
|
|
ret <4 x float> %res
|
|
|
|
}
|
|
|
|
|
2015-12-31 17:45:16 +08:00
|
|
|
define float @rsqrtss_size(float* %a) optsize {
|
|
|
|
; SSE-LABEL: rsqrtss_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2015-12-31 17:45:16 +08:00
|
|
|
; SSE-NEXT: rsqrtss (%rdi), %xmm0
|
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: rsqrtss_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2015-12-31 17:45:16 +08:00
|
|
|
; AVX-NEXT: vrsqrtss (%rdi), %xmm0, %xmm0
|
|
|
|
; AVX-NEXT: retq
|
|
|
|
%ld = load float, float* %a
|
|
|
|
%ins = insertelement <4 x float> undef, float %ld, i32 0
|
|
|
|
%res = tail call <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float> %ins)
|
|
|
|
%ext = extractelement <4 x float> %res, i32 0
|
|
|
|
ret float %ext
|
|
|
|
}
|
|
|
|
|
2017-11-13 13:25:23 +08:00
|
|
|
define <4 x float> @rsqrtss_full_size(<4 x float>* %a) optsize {
|
|
|
|
; SSE-LABEL: rsqrtss_full_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2017-11-13 13:25:24 +08:00
|
|
|
; SSE-NEXT: rsqrtss (%rdi), %xmm0
|
2017-11-13 13:25:23 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: rsqrtss_full_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2017-11-13 13:25:24 +08:00
|
|
|
; AVX-NEXT: vrsqrtss (%rdi), %xmm0, %xmm0
|
2017-11-13 13:25:23 +08:00
|
|
|
; AVX-NEXT: retq
|
|
|
|
%ld = load <4 x float>, <4 x float>* %a
|
|
|
|
%res = tail call <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float> %ld)
|
|
|
|
ret <4 x float> %res
|
|
|
|
}
|
|
|
|
|
2015-12-31 17:45:16 +08:00
|
|
|
define float @sqrtss_size(float* %a) optsize{
|
|
|
|
; SSE-LABEL: sqrtss_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2015-12-31 17:45:16 +08:00
|
|
|
; SSE-NEXT: sqrtss (%rdi), %xmm0
|
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: sqrtss_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2015-12-31 17:45:16 +08:00
|
|
|
; AVX-NEXT: vsqrtss (%rdi), %xmm0, %xmm0
|
|
|
|
; AVX-NEXT: retq
|
|
|
|
%ld = load float, float* %a
|
|
|
|
%ins = insertelement <4 x float> undef, float %ld, i32 0
|
|
|
|
%res = tail call <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float> %ins)
|
|
|
|
%ext = extractelement <4 x float> %res, i32 0
|
|
|
|
ret float %ext
|
|
|
|
}
|
|
|
|
|
2017-11-13 13:25:23 +08:00
|
|
|
define <4 x float> @sqrtss_full_size(<4 x float>* %a) optsize{
|
|
|
|
; SSE-LABEL: sqrtss_full_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2017-11-13 13:25:24 +08:00
|
|
|
; SSE-NEXT: sqrtss (%rdi), %xmm0
|
2017-11-13 13:25:23 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: sqrtss_full_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2017-11-13 13:25:24 +08:00
|
|
|
; AVX-NEXT: vsqrtss (%rdi), %xmm0, %xmm0
|
2017-11-13 13:25:23 +08:00
|
|
|
; AVX-NEXT: retq
|
|
|
|
%ld = load <4 x float>, <4 x float>* %a
|
|
|
|
%res = tail call <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float> %ld)
|
|
|
|
ret <4 x float> %res
|
|
|
|
}
|
|
|
|
|
2015-12-31 17:45:16 +08:00
|
|
|
define double @sqrtsd_size(double* %a) optsize {
|
|
|
|
; SSE-LABEL: sqrtsd_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2015-12-31 17:45:16 +08:00
|
|
|
; SSE-NEXT: sqrtsd (%rdi), %xmm0
|
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: sqrtsd_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2015-12-31 17:45:16 +08:00
|
|
|
; AVX-NEXT: vsqrtsd (%rdi), %xmm0, %xmm0
|
|
|
|
; AVX-NEXT: retq
|
|
|
|
%ld = load double, double* %a
|
|
|
|
%ins = insertelement <2 x double> undef, double %ld, i32 0
|
|
|
|
%res = tail call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %ins)
|
|
|
|
%ext = extractelement <2 x double> %res, i32 0
|
|
|
|
ret double %ext
|
|
|
|
}
|
2015-02-20 00:59:11 +08:00
|
|
|
|
2017-11-13 13:25:23 +08:00
|
|
|
define <2 x double> @sqrtsd_full_size(<2 x double>* %a) optsize {
|
|
|
|
; SSE-LABEL: sqrtsd_full_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SSE: # %bb.0:
|
2017-11-13 13:25:24 +08:00
|
|
|
; SSE-NEXT: sqrtsd (%rdi), %xmm0
|
2017-11-13 13:25:23 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: sqrtsd_full_size:
|
2017-12-05 01:18:51 +08:00
|
|
|
; AVX: # %bb.0:
|
2017-11-13 13:25:24 +08:00
|
|
|
; AVX-NEXT: vsqrtsd (%rdi), %xmm0, %xmm0
|
2017-11-13 13:25:23 +08:00
|
|
|
; AVX-NEXT: retq
|
|
|
|
%ld = load <2 x double>, <2 x double>* %a
|
|
|
|
%res = tail call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %ld)
|
|
|
|
ret <2 x double> %res
|
|
|
|
}
|
|
|
|
|
2015-02-20 00:59:11 +08:00
|
|
|
declare <4 x float> @llvm.x86.sse.rcp.ss(<4 x float>) nounwind readnone
|
|
|
|
declare <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float>) nounwind readnone
|
|
|
|
declare <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float>) nounwind readnone
|
|
|
|
declare <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double>) nounwind readnone
|