[llvm] 6fc0bc5 - Fix behavior of is_fp_class on empty class set

Serge Pavlov via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 07:51:13 PDT 2022


Author: Serge Pavlov
Date: 2022-05-24T21:50:18+07:00
New Revision: 6fc0bc5b0fa7b87960a8b326853643df503d76f7

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

LOG: Fix behavior of is_fp_class on empty class set

The second argument to is_fp_class specifies the set of floating-point
class to test against. It can be zero, in this case the intrinsic is
expected to return zero value.

Differential Revision: https://reviews.llvm.org/D112025

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
    llvm/test/CodeGen/X86/is_fpclass.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 5af1cd8d4f53..5cf5aa9c2980 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -7446,7 +7446,9 @@ SDValue TargetLowering::expandIS_FPCLASS(EVT ResultVT, SDValue Op,
   assert(OperandVT.isFloatingPoint());
 
   // Degenerated cases.
-  if (Test == 0 || (Test & fcAllFlags) == fcAllFlags)
+  if (Test == 0)
+    return DAG.getBoolConstant(false, DL, ResultVT, OperandVT);
+  if ((Test & fcAllFlags) == fcAllFlags)
     return DAG.getBoolConstant(true, DL, ResultVT, OperandVT);
 
   // PPC double double is a pair of doubles, of which the higher part determines

diff  --git a/llvm/test/CodeGen/X86/is_fpclass.ll b/llvm/test/CodeGen/X86/is_fpclass.ll
index 3929141f6922..6ef60023eac7 100644
--- a/llvm/test/CodeGen/X86/is_fpclass.ll
+++ b/llvm/test/CodeGen/X86/is_fpclass.ll
@@ -935,6 +935,37 @@ entry:
   ret <4 x i1> %0
 }
 
+define i1 @isnone_f(float %x) {
+; CHECK-32-LABEL: isnone_f:
+; CHECK-32:       # %bb.0: # %entry
+; CHECK-32-NEXT:    xorl %eax, %eax
+; CHECK-32-NEXT:    retl
+;
+; CHECK-64-LABEL: isnone_f:
+; CHECK-64:       # %bb.0: # %entry
+; CHECK-64-NEXT:    xorl %eax, %eax
+; CHECK-64-NEXT:    retq
+entry:
+  %0 = tail call i1 @llvm.is.fpclass.f32(float %x, i32 0)
+  ret i1 %0
+}
+
+define i1 @isany_f(float %x) {
+; CHECK-32-LABEL: isany_f:
+; CHECK-32:       # %bb.0: # %entry
+; CHECK-32-NEXT:    movb $1, %al
+; CHECK-32-NEXT:    retl
+;
+; CHECK-64-LABEL: isany_f:
+; CHECK-64:       # %bb.0: # %entry
+; CHECK-64-NEXT:    movb $1, %al
+; CHECK-64-NEXT:    retq
+entry:
+  %0 = tail call i1 @llvm.is.fpclass.f32(float %x, i32 1023)
+  ret i1 %0
+}
+
+
 
 declare i1 @llvm.is.fpclass.f32(float, i32)
 declare i1 @llvm.is.fpclass.f64(double, i32)


        


More information about the llvm-commits mailing list