[llvm] b29e5cd - [X86] Add test cases for most of the constrained fp libcalls with fp128.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 21 18:32:06 PST 2019


Author: Craig Topper
Date: 2019-11-21T18:17:59-08:00
New Revision: b29e5cdb7c98c93e16955e58efeb922da93f969f

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

LOG: [X86] Add test cases for most of the constrained fp libcalls with fp128.

Add explicit setOperation actions for some to match their none
strict counterparts. This isn't required, but makes the code
self documenting that we didn't forget about strict fp. I've
used LibCall instead of Expand since that's more explicitly what
we want.

Only lrint/llrint/lround/llround are missing now.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ISelLowering.cpp
    llvm/test/CodeGen/X86/fp128-libcalls-strict.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index bef8c8ab1ca0..dfffd19dd628 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -681,10 +681,14 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
     setOperationAction(ISD::FNEG, MVT::f128, Custom);
     setOperationAction(ISD::FCOPYSIGN, MVT::f128, Custom);
 
-    setOperationAction(ISD::FSIN,    MVT::f128, Expand);
-    setOperationAction(ISD::FCOS,    MVT::f128, Expand);
-    setOperationAction(ISD::FSINCOS, MVT::f128, Expand);
-    setOperationAction(ISD::FSQRT,   MVT::f128, Expand);
+    setOperationAction(ISD::FSIN,         MVT::f128, LibCall);
+    setOperationAction(ISD::STRICT_FSIN,  MVT::f128, LibCall);
+    setOperationAction(ISD::FCOS,         MVT::f128, LibCall);
+    setOperationAction(ISD::STRICT_FCOS,  MVT::f128, LibCall);
+    setOperationAction(ISD::FSINCOS,      MVT::f128, LibCall);
+    // No STRICT_FSINCOS
+    setOperationAction(ISD::FSQRT,        MVT::f128, LibCall);
+    setOperationAction(ISD::STRICT_FSQRT, MVT::f128, LibCall);
 
     setOperationAction(ISD::FP_EXTEND, MVT::f128, Custom);
     // We need to custom handle any FP_ROUND with an f128 input, but

diff  --git a/llvm/test/CodeGen/X86/fp128-libcalls-strict.ll b/llvm/test/CodeGen/X86/fp128-libcalls-strict.ll
index 3bd028af8433..c7de03ca5e22 100644
--- a/llvm/test/CodeGen/X86/fp128-libcalls-strict.ll
+++ b/llvm/test/CodeGen/X86/fp128-libcalls-strict.ll
@@ -66,6 +66,234 @@ entry:
   ret fp128 %fma
 }
 
+define fp128 @frem(fp128 %x, fp128 %y) nounwind strictfp {
+; CHECK-LABEL: frem:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq fmodl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %div = call fp128 @llvm.experimental.constrained.frem.f128(fp128 %x, fp128 %y,  metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %div
+}
+
+define fp128 @ceil(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: ceil:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq ceill
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %ceil = call fp128 @llvm.experimental.constrained.ceil.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %ceil
+}
+
+define fp128 @cos(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: cos:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq cosl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %cos = call fp128 @llvm.experimental.constrained.cos.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %cos
+}
+
+define fp128 @exp(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: exp:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq expl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %exp = call fp128 @llvm.experimental.constrained.exp.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %exp
+}
+
+define fp128 @exp2(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: exp2:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq exp2l
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %exp2 = call fp128 @llvm.experimental.constrained.exp2.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %exp2
+}
+
+define fp128 @floor(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: floor:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq floorl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %floor = call fp128 @llvm.experimental.constrained.floor.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %floor
+}
+
+define fp128 @log(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: log:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq logl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %log = call fp128 @llvm.experimental.constrained.log.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %log
+}
+
+define fp128 @log10(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: log10:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq log10l
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %log10 = call fp128 @llvm.experimental.constrained.log10.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %log10
+}
+
+define fp128 @log2(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: log2:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq log2l
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %log2 = call fp128 @llvm.experimental.constrained.log2.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %log2
+}
+
+define fp128 @maxnum(fp128 %x, fp128 %y) nounwind strictfp {
+; CHECK-LABEL: maxnum:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq fmaxl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %maxnum = call fp128 @llvm.experimental.constrained.maxnum.f128(fp128 %x, fp128 %y, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %maxnum
+}
+
+define fp128 @minnum(fp128 %x, fp128 %y) nounwind strictfp {
+; CHECK-LABEL: minnum:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq fminl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %minnum = call fp128 @llvm.experimental.constrained.minnum.f128(fp128 %x, fp128 %y, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %minnum
+}
+
+define fp128 @nearbyint(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: nearbyint:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq nearbyintl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %nearbyint = call fp128 @llvm.experimental.constrained.nearbyint.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %nearbyint
+}
+
+define fp128 @pow(fp128 %x, fp128 %y) nounwind strictfp {
+; CHECK-LABEL: pow:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq powl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %pow = call fp128 @llvm.experimental.constrained.pow.f128(fp128 %x, fp128 %y, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %pow
+}
+
+define fp128 @powi(fp128 %x, i32 %y) nounwind strictfp {
+; CHECK-LABEL: powi:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq __powitf2
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %powi = call fp128 @llvm.experimental.constrained.powi.f128(fp128 %x, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %powi
+}
+
+define fp128 @rint(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: rint:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq rintl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %rint = call fp128 @llvm.experimental.constrained.rint.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %rint
+}
+
+define fp128 @round(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: round:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq roundl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %round = call fp128 @llvm.experimental.constrained.round.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %round
+}
+
+define fp128 @sin(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: sin:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq sinl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %sin = call fp128 @llvm.experimental.constrained.sin.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %sin
+}
+
+define fp128 @sqrt(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: sqrt:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq sqrtl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %sqrt = call fp128 @llvm.experimental.constrained.sqrt.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %sqrt
+}
+
+define fp128 @trunc(fp128 %x) nounwind strictfp {
+; CHECK-LABEL: trunc:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq truncl
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %trunc = call fp128 @llvm.experimental.constrained.trunc.f128(fp128 %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
+  ret fp128 %trunc
+}
+
 attributes #0 = { strictfp }
 
 declare fp128 @llvm.experimental.constrained.fadd.f128(fp128, fp128, metadata, metadata)
@@ -73,3 +301,22 @@ declare fp128 @llvm.experimental.constrained.fsub.f128(fp128, fp128, metadata, m
 declare fp128 @llvm.experimental.constrained.fmul.f128(fp128, fp128, metadata, metadata)
 declare fp128 @llvm.experimental.constrained.fdiv.f128(fp128, fp128, metadata, metadata)
 declare fp128 @llvm.experimental.constrained.fma.f128(fp128, fp128, fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.frem.f128(fp128, fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.ceil.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.cos.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.exp.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.exp2.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.floor.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.log.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.log10.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.log2.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.maxnum.f128(fp128, fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.minnum.f128(fp128, fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.nearbyint.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.pow.f128(fp128, fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.powi.f128(fp128, i32, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.rint.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.round.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.sin.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.sqrt.f128(fp128, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.trunc.f128(fp128, metadata, metadata)


        


More information about the llvm-commits mailing list