[llvm] 9ff05dc - [x86] add another test for reciprocal sqrt; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 06:41:23 PDT 2020


Author: Sanjay Patel
Date: 2020-08-31T09:35:59-04:00
New Revision: 9ff05dcd38f72871821a03f20f41092026e5cba0

URL: https://github.com/llvm/llvm-project/commit/9ff05dcd38f72871821a03f20f41092026e5cba0
DIFF: https://github.com/llvm/llvm-project/commit/9ff05dcd38f72871821a03f20f41092026e5cba0.diff

LOG: [x86] add another test for reciprocal sqrt; NFC

The change in rG716e35a0cf53 depends on the order that
we encounter the expression x/sqrt(x), so we need to
adjust the logic to be more flexible.

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 f69b375b062c..9735e46eb9c9 100644
--- a/llvm/test/CodeGen/X86/sqrt-fastmath.ll
+++ b/llvm/test/CodeGen/X86/sqrt-fastmath.ll
@@ -994,6 +994,33 @@ define <2 x double> @sqrt_simplify_before_recip_vec(<2 x double> %x, <2 x double
   ret <2 x double> %sqrt_fast
 }
 
+define double @sqrt_simplify_before_recip_order(double %x, double* %p) nounwind {
+; SSE-LABEL: sqrt_simplify_before_recip_order:
+; 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:    mulsd {{.*}}(%rip), %xmm2
+; SSE-NEXT:    movsd %xmm2, (%rdi)
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: sqrt_simplify_before_recip_order:
+; 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:    vmulsd {{.*}}(%rip), %xmm1, %xmm1
+; AVX-NEXT:    vmovsd %xmm1, (%rdi)
+; AVX-NEXT:    retq
+  %sqrt = tail call fast double @llvm.sqrt.f64(double %x)
+  %sqrt_fast = fdiv fast double %x, %sqrt
+  %rsqrt = fdiv fast double 42.0, %sqrt
+  store double %rsqrt, double* %p, align 8
+  ret 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