[llvm] r318630 - [x86] add sqrt tests for partially-inline-libcalls (PR31455)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 19 09:31:37 PST 2017


Author: spatel
Date: Sun Nov 19 09:31:37 2017
New Revision: 318630

URL: http://llvm.org/viewvc/llvm-project?rev=318630&view=rev
Log:
[x86] add sqrt tests for partially-inline-libcalls (PR31455)

Added:
    llvm/trunk/test/CodeGen/X86/sqrt-partial.ll

Added: llvm/trunk/test/CodeGen/X86/sqrt-partial.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sqrt-partial.ll?rev=318630&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/sqrt-partial.ll (added)
+++ llvm/trunk/test/CodeGen/X86/sqrt-partial.ll Sun Nov 19 09:31:37 2017
@@ -0,0 +1,43 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
+
+; PR31455 - https://bugs.llvm.org/show_bug.cgi?id=31455
+; We have to assume that errno can be set, so we have to make a libcall in that case.
+; But it's better for perf to check that the argument is valid rather than the result of 
+; sqrtss/sqrtsd.
+; Note: This is really a test of the -partially-inline-libcalls IR pass (and we have an IR test
+; for that), but we're checking the final asm to make sure that comes out as expected too.
+
+define float @f(float %val) nounwind {
+; CHECK-LABEL: f:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    sqrtss %xmm0, %xmm1
+; CHECK-NEXT:    ucomiss %xmm1, %xmm1
+; CHECK-NEXT:    jp .LBB0_2
+; CHECK-NEXT:  # BB#1: # %.split
+; CHECK-NEXT:    movaps %xmm1, %xmm0
+; CHECK-NEXT:    retq
+; CHECK-NEXT:  .LBB0_2: # %call.sqrt
+; CHECK-NEXT:    jmp sqrtf # TAILCALL
+  %res = tail call float @sqrtf(float %val)
+  ret float %res
+}
+
+define double @d(double %val) nounwind {
+; CHECK-LABEL: d:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    sqrtsd %xmm0, %xmm1
+; CHECK-NEXT:    ucomisd %xmm1, %xmm1
+; CHECK-NEXT:    jp .LBB1_2
+; CHECK-NEXT:  # BB#1: # %.split
+; CHECK-NEXT:    movapd %xmm1, %xmm0
+; CHECK-NEXT:    retq
+; CHECK-NEXT:  .LBB1_2: # %call.sqrt
+; CHECK-NEXT:    jmp sqrt # TAILCALL
+  %res = tail call double @sqrt(double %val)
+  ret double %res
+}
+
+declare float @sqrtf(float)
+declare double @sqrt(double)
+




More information about the llvm-commits mailing list