[llvm] r354408 - Revert "[InstSimplify] use any-zero matcher for fcmp folds"

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 19 16:20:39 PST 2019


Author: spatel
Date: Tue Feb 19 16:20:38 2019
New Revision: 354408

URL: http://llvm.org/viewvc/llvm-project?rev=354408&view=rev
Log:
Revert "[InstSimplify] use any-zero matcher for fcmp folds"

This reverts commit 058bb8351351d56d2a4e8a772570231f9e5305e5.
Forgot to update another test affected by this change.

Modified:
    llvm/trunk/lib/Analysis/InstructionSimplify.cpp
    llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll

Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=354408&r1=354407&r2=354408&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Tue Feb 19 16:20:38 2019
@@ -3648,31 +3648,6 @@ static Value *SimplifyFCmpInst(unsigned
   }
 
   // Handle fcmp with constant RHS.
-  if (match(RHS, m_AnyZeroFP())) {
-    switch (Pred) {
-    case FCmpInst::FCMP_OGE:
-      if (FMF.noNaNs() && CannotBeOrderedLessThanZero(LHS, Q.TLI))
-        return getTrue(RetTy);
-      break;
-    case FCmpInst::FCMP_UGE:
-      if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
-        return getTrue(RetTy);
-      break;
-    case FCmpInst::FCMP_ULT:
-      if (FMF.noNaNs() && CannotBeOrderedLessThanZero(LHS, Q.TLI))
-        return getFalse(RetTy);
-      break;
-    case FCmpInst::FCMP_OLT:
-      if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
-        return getFalse(RetTy);
-      break;
-    default:
-      break;
-    }
-  }
-
-  // TODO: Use match with a specific FP value, so these work with vectors with
-  // undef lanes.
   const APFloat *C;
   if (match(RHS, m_APFloat(C))) {
     // Check whether the constant is an infinity.
@@ -3700,6 +3675,28 @@ static Value *SimplifyFCmpInst(unsigned
           break;
         }
       }
+    }
+    if (C->isZero()) {
+      switch (Pred) {
+      case FCmpInst::FCMP_OGE:
+        if (FMF.noNaNs() && CannotBeOrderedLessThanZero(LHS, Q.TLI))
+          return getTrue(RetTy);
+        break;
+      case FCmpInst::FCMP_UGE:
+        if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
+          return getTrue(RetTy);
+        break;
+      case FCmpInst::FCMP_ULT:
+        if (FMF.noNaNs() && CannotBeOrderedLessThanZero(LHS, Q.TLI))
+          return getFalse(RetTy);
+        break;
+      case FCmpInst::FCMP_OLT:
+        if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
+          return getFalse(RetTy);
+        break;
+      default:
+        break;
+      }
     } else if (C->isNegative()) {
       assert(!C->isNaN() && "Unexpected NaN constant!");
       // TODO: We can catch more cases by using a range check rather than

Modified: llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll?rev=354408&r1=354407&r2=354408&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll Tue Feb 19 16:20:38 2019
@@ -399,7 +399,9 @@ define <2 x i1> @fabs_is_not_negative_po
 
 define <2 x i1> @fabs_is_not_negative_anyzero(<2 x float> %V) {
 ; CHECK-LABEL: @fabs_is_not_negative_anyzero(
-; CHECK-NEXT:    ret <2 x i1> zeroinitializer
+; CHECK-NEXT:    [[ABS:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[V:%.*]])
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <2 x float> [[ABS]], <float 0.000000e+00, float -0.000000e+00>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
 ;
   %abs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %V)
   %cmp = fcmp olt <2 x float> %abs, <float 0.0, float -0.0>
@@ -408,7 +410,9 @@ define <2 x i1> @fabs_is_not_negative_an
 
 define <3 x i1> @fabs_is_not_negative_negzero_undef(<3 x float> %V) {
 ; CHECK-LABEL: @fabs_is_not_negative_negzero_undef(
-; CHECK-NEXT:    ret <3 x i1> zeroinitializer
+; CHECK-NEXT:    [[ABS:%.*]] = call <3 x float> @llvm.fabs.v3f32(<3 x float> [[V:%.*]])
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <3 x float> [[ABS]], <float -0.000000e+00, float -0.000000e+00, float undef>
+; CHECK-NEXT:    ret <3 x i1> [[CMP]]
 ;
   %abs = call <3 x float> @llvm.fabs.v3f32(<3 x float> %V)
   %cmp = fcmp olt <3 x float> %abs, <float -0.0, float -0.0, float undef>
@@ -417,7 +421,9 @@ define <3 x i1> @fabs_is_not_negative_ne
 
 define <3 x i1> @fabs_is_not_negative_poszero_undef(<3 x float> %V) {
 ; CHECK-LABEL: @fabs_is_not_negative_poszero_undef(
-; CHECK-NEXT:    ret <3 x i1> zeroinitializer
+; CHECK-NEXT:    [[ABS:%.*]] = call <3 x float> @llvm.fabs.v3f32(<3 x float> [[V:%.*]])
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <3 x float> [[ABS]], <float 0.000000e+00, float 0.000000e+00, float undef>
+; CHECK-NEXT:    ret <3 x i1> [[CMP]]
 ;
   %abs = call <3 x float> @llvm.fabs.v3f32(<3 x float> %V)
   %cmp = fcmp olt <3 x float> %abs, <float 0.0, float 0.0, float undef>
@@ -426,7 +432,9 @@ define <3 x i1> @fabs_is_not_negative_po
 
 define <3 x i1> @fabs_is_not_negative_anyzero_undef(<3 x float> %V) {
 ; CHECK-LABEL: @fabs_is_not_negative_anyzero_undef(
-; CHECK-NEXT:    ret <3 x i1> zeroinitializer
+; CHECK-NEXT:    [[ABS:%.*]] = call <3 x float> @llvm.fabs.v3f32(<3 x float> [[V:%.*]])
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <3 x float> [[ABS]], <float 0.000000e+00, float -0.000000e+00, float undef>
+; CHECK-NEXT:    ret <3 x i1> [[CMP]]
 ;
   %abs = call <3 x float> @llvm.fabs.v3f32(<3 x float> %V)
   %cmp = fcmp olt <3 x float> %abs, <float 0.0, float -0.0, float undef>




More information about the llvm-commits mailing list