[llvm] ed5fe00 - [x86] add tests for multi-use fast sqrt/recip; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 30 08:01:35 PDT 2020
Author: Sanjay Patel
Date: 2020-08-30T10:55:44-04:00
New Revision: ed5fe00e72b0c6dbb71c692cc6a932308b86179d
URL: https://github.com/llvm/llvm-project/commit/ed5fe00e72b0c6dbb71c692cc6a932308b86179d
DIFF: https://github.com/llvm/llvm-project/commit/ed5fe00e72b0c6dbb71c692cc6a932308b86179d.diff
LOG: [x86] add tests for multi-use fast sqrt/recip; NFC
Added:
Modified:
llvm/test/CodeGen/X86/sqrt-fastmath.ll
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/X86/sqrt-fastmath.ll b/llvm/test/CodeGen/X86/sqrt-fastmath.ll
index 49c0b8b30fbb..e44eb613eb13 100644
--- a/llvm/test/CodeGen/X86/sqrt-fastmath.ll
+++ b/llvm/test/CodeGen/X86/sqrt-fastmath.ll
@@ -948,6 +948,56 @@ define double @sqrt_fdiv_common_operand_extra_use(double %x, double* %p) nounwin
ret double %r
}
+define double @sqrt_simplify_before_recip(double %x, double* %p) nounwind {
+; SSE-LABEL: sqrt_simplify_before_recip:
+; SSE: # %bb.0:
+; SSE-NEXT: sqrtsd %xmm0, %xmm1
+; SSE-NEXT: movsd {{.*#+}} xmm2 = mem[0],zero
+; SSE-NEXT: divsd %xmm1, %xmm2
+; SSE-NEXT: mulsd %xmm2, %xmm0
+; SSE-NEXT: movsd %xmm2, (%rdi)
+; SSE-NEXT: retq
+;
+; AVX-LABEL: sqrt_simplify_before_recip:
+; AVX: # %bb.0:
+; AVX-NEXT: vsqrtsd %xmm0, %xmm0, %xmm1
+; AVX-NEXT: vmovsd {{.*#+}} xmm2 = mem[0],zero
+; AVX-NEXT: vdivsd %xmm1, %xmm2, %xmm1
+; AVX-NEXT: vmulsd %xmm1, %xmm0, %xmm0
+; AVX-NEXT: vmovsd %xmm1, (%rdi)
+; AVX-NEXT: retq
+ %sqrt = tail call fast double @llvm.sqrt.f64(double %x)
+ %rsqrt = fdiv fast double 1.0, %sqrt
+ %sqrt_fast = fdiv fast double %x, %sqrt
+ store double %rsqrt, double* %p, align 8
+ ret double %sqrt_fast
+}
+
+define <2 x double> @sqrt_simplify_before_recip_vec(<2 x double> %x, <2 x double>* %p) nounwind {
+; SSE-LABEL: sqrt_simplify_before_recip_vec:
+; SSE: # %bb.0:
+; SSE-NEXT: sqrtpd %xmm0, %xmm1
+; SSE-NEXT: movapd {{.*#+}} xmm2 = [1.0E+0,1.0E+0]
+; SSE-NEXT: divpd %xmm1, %xmm2
+; SSE-NEXT: mulpd %xmm2, %xmm0
+; SSE-NEXT: movupd %xmm2, (%rdi)
+; SSE-NEXT: retq
+;
+; AVX-LABEL: sqrt_simplify_before_recip_vec:
+; AVX: # %bb.0:
+; AVX-NEXT: vsqrtpd %xmm0, %xmm1
+; AVX-NEXT: vmovapd {{.*#+}} xmm2 = [1.0E+0,1.0E+0]
+; AVX-NEXT: vdivpd %xmm1, %xmm2, %xmm1
+; AVX-NEXT: vmulpd %xmm1, %xmm0, %xmm0
+; AVX-NEXT: vmovupd %xmm1, (%rdi)
+; AVX-NEXT: retq
+ %sqrt = tail call fast <2 x double> @llvm.sqrt.v2f64(<2 x double> %x)
+ %rsqrt = fdiv fast <2 x double> <double 1.0, double 1.0>, %sqrt
+ %sqrt_fast = fdiv fast <2 x double> %x, %sqrt
+ store <2 x double> %rsqrt, <2 x double>* %p, align 8
+ ret <2 x double> %sqrt_fast
+}
+
attributes #0 = { "unsafe-fp-math"="true" "reciprocal-estimates"="!sqrtf,!vec-sqrtf,!divf,!vec-divf" }
attributes #1 = { "unsafe-fp-math"="true" "reciprocal-estimates"="sqrt,vec-sqrt" }
attributes #2 = { nounwind readnone }
More information about the llvm-commits
mailing list