[llvm] b083d7a - [PowerPC] Fix the unexpected modification caused by D62993 in LowerSELECT_CC for power9

Kang Zhang via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 25 18:59:50 PST 2020


Author: Kang Zhang
Date: 2020-02-26T02:59:03Z
New Revision: b083d7a3460d28884a1e2f7dae5a93465cd1099e

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

LOG: [PowerPC] Fix the unexpected modification caused by D62993 in LowerSELECT_CC for power9

Summary:
The patch D62993 : `[PowerPC] Emit scalar min/max instructions with unsafe fp math`
has modified the functionality when `Subtarget.hasP9Vector() && (!HasNoInfs || !HasNoNaNs)`,
 this modification is not expected.

Reviewed By: nemanjai

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

Added: 
    

Modified: 
    llvm/lib/Target/PowerPC/PPCISelLowering.cpp
    llvm/test/CodeGen/PowerPC/scalar-equal.ll
    llvm/test/CodeGen/PowerPC/scalar_cmp.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 06af06c5d87b..9757c1f85c20 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -7582,7 +7582,8 @@ SDValue PPCTargetLowering::LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const {
     case ISD::SETLT:
       return DAG.getNode(PPCISD::XSMINCDP, dl, Op.getValueType(), LHS, RHS);
     }
-  }
+  } else if (!HasNoInfs || !HasNoNaNs)
+    return Op;
 
   // TODO: Propagate flags from the select rather than global settings.
   SDNodeFlags Flags;

diff  --git a/llvm/test/CodeGen/PowerPC/scalar-equal.ll b/llvm/test/CodeGen/PowerPC/scalar-equal.ll
index 5b58d7f3d6e1..3cd570b712dd 100644
--- a/llvm/test/CodeGen/PowerPC/scalar-equal.ll
+++ b/llvm/test/CodeGen/PowerPC/scalar-equal.ll
@@ -35,10 +35,12 @@ define double @testoeq(double %a, double %b, double %c, double %d) {
 ;
 ; NO-FAST-P9-LABEL: testoeq:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubdp f0, f1, f2
-; NO-FAST-P9-NEXT:    fsel f1, f0, f3, f4
-; NO-FAST-P9-NEXT:    xsnegdp f0, f0
-; NO-FAST-P9-NEXT:    fsel f1, f0, f1, f4
+; NO-FAST-P9-NEXT:    xscmpudp cr0, f1, f2
+; NO-FAST-P9-NEXT:    beq cr0, .LBB0_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB0_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 ;
 ; NO-FAST-P8-LABEL: testoeq:

diff  --git a/llvm/test/CodeGen/PowerPC/scalar_cmp.ll b/llvm/test/CodeGen/PowerPC/scalar_cmp.ll
index 9b2857a761e2..365e0e4e55d6 100644
--- a/llvm/test/CodeGen/PowerPC/scalar_cmp.ll
+++ b/llvm/test/CodeGen/PowerPC/scalar_cmp.ll
@@ -127,10 +127,12 @@ define float @select_fast_oeq_float(float %a, float %b, float %c, float %d) {
 ;
 ; NO-FAST-P9-LABEL: select_fast_oeq_float:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubsp f0, f1, f2
-; NO-FAST-P9-NEXT:    xsnegdp f1, f0
-; NO-FAST-P9-NEXT:    fsel f0, f0, f3, f4
-; NO-FAST-P9-NEXT:    fsel f1, f1, f0, f4
+; NO-FAST-P9-NEXT:    fcmpu cr0, f1, f2
+; NO-FAST-P9-NEXT:    beq cr0, .LBB2_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB2_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast oeq float %a, %b
@@ -166,10 +168,12 @@ define double @select_fast_oeq_double(double %a, double %b, double %c, double %d
 ;
 ; NO-FAST-P9-LABEL: select_fast_oeq_double:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubdp f0, f1, f2
-; NO-FAST-P9-NEXT:    fsel f1, f0, f3, f4
-; NO-FAST-P9-NEXT:    xsnegdp f0, f0
-; NO-FAST-P9-NEXT:    fsel f1, f0, f1, f4
+; NO-FAST-P9-NEXT:    xscmpudp cr0, f1, f2
+; NO-FAST-P9-NEXT:    beq cr0, .LBB3_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB3_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast oeq double %a, %b
@@ -293,10 +297,12 @@ define float @select_fast_one_float(float %a, float %b, float %c, float %d) {
 ;
 ; NO-FAST-P9-LABEL: select_fast_one_float:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubsp f0, f1, f2
-; NO-FAST-P9-NEXT:    xsnegdp f1, f0
-; NO-FAST-P9-NEXT:    fsel f0, f0, f4, f3
-; NO-FAST-P9-NEXT:    fsel f1, f1, f0, f3
+; NO-FAST-P9-NEXT:    fcmpu cr0, f1, f2
+; NO-FAST-P9-NEXT:    bne cr0, .LBB6_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB6_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast one float %a, %b
@@ -332,10 +338,12 @@ define double @select_fast_one_double(double %a, double %b, double %c, double %d
 ;
 ; NO-FAST-P9-LABEL: select_fast_one_double:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubdp f0, f1, f2
-; NO-FAST-P9-NEXT:    fsel f1, f0, f4, f3
-; NO-FAST-P9-NEXT:    xsnegdp f0, f0
-; NO-FAST-P9-NEXT:    fsel f1, f0, f1, f3
+; NO-FAST-P9-NEXT:    xscmpudp cr0, f1, f2
+; NO-FAST-P9-NEXT:    bne cr0, .LBB7_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB7_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast one double %a, %b
@@ -447,8 +455,12 @@ define float @select_fast_oge_float(float %a, float %b, float %c, float %d) {
 ;
 ; NO-FAST-P9-LABEL: select_fast_oge_float:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubsp f0, f1, f2
-; NO-FAST-P9-NEXT:    fsel f1, f0, f3, f4
+; NO-FAST-P9-NEXT:    fcmpu cr0, f1, f2
+; NO-FAST-P9-NEXT:    bge cr0, .LBB10_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB10_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast oge float %a, %b
@@ -480,8 +492,12 @@ define double @select_fast_oge_double(double %a, double %b, double %c, double %d
 ;
 ; NO-FAST-P9-LABEL: select_fast_oge_double:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubdp f0, f1, f2
-; NO-FAST-P9-NEXT:    fsel f1, f0, f3, f4
+; NO-FAST-P9-NEXT:    xscmpudp cr0, f1, f2
+; NO-FAST-P9-NEXT:    bge cr0, .LBB11_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB11_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast oge double %a, %b
@@ -589,8 +605,12 @@ define float @select_fast_olt_float(float %a, float %b, float %c, float %d) {
 ;
 ; NO-FAST-P9-LABEL: select_fast_olt_float:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubsp f0, f1, f2
-; NO-FAST-P9-NEXT:    fsel f1, f0, f4, f3
+; NO-FAST-P9-NEXT:    fcmpu cr0, f1, f2
+; NO-FAST-P9-NEXT:    blt cr0, .LBB14_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB14_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast olt float %a, %b
@@ -622,8 +642,12 @@ define double @select_fast_olt_double(double %a, double %b, double %c, double %d
 ;
 ; NO-FAST-P9-LABEL: select_fast_olt_double:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubdp f0, f1, f2
-; NO-FAST-P9-NEXT:    fsel f1, f0, f4, f3
+; NO-FAST-P9-NEXT:    xscmpudp cr0, f1, f2
+; NO-FAST-P9-NEXT:    blt cr0, .LBB15_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB15_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast olt double %a, %b
@@ -731,8 +755,12 @@ define float @select_fast_ogt_float(float %a, float %b, float %c, float %d) {
 ;
 ; NO-FAST-P9-LABEL: select_fast_ogt_float:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubsp f0, f2, f1
-; NO-FAST-P9-NEXT:    fsel f1, f0, f4, f3
+; NO-FAST-P9-NEXT:    fcmpu cr0, f1, f2
+; NO-FAST-P9-NEXT:    bgt cr0, .LBB18_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB18_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast ogt float %a, %b
@@ -764,8 +792,12 @@ define double @select_fast_ogt_double(double %a, double %b, double %c, double %d
 ;
 ; NO-FAST-P9-LABEL: select_fast_ogt_double:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubdp f0, f2, f1
-; NO-FAST-P9-NEXT:    fsel f1, f0, f4, f3
+; NO-FAST-P9-NEXT:    xscmpudp cr0, f1, f2
+; NO-FAST-P9-NEXT:    bgt cr0, .LBB19_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB19_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast ogt double %a, %b
@@ -877,8 +909,12 @@ define float @select_fast_ole_float(float %a, float %b, float %c, float %d) {
 ;
 ; NO-FAST-P9-LABEL: select_fast_ole_float:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubsp f0, f2, f1
-; NO-FAST-P9-NEXT:    fsel f1, f0, f3, f4
+; NO-FAST-P9-NEXT:    fcmpu cr0, f1, f2
+; NO-FAST-P9-NEXT:    ble cr0, .LBB22_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB22_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast ole float %a, %b
@@ -910,8 +946,12 @@ define double @select_fast_ole_double(double %a, double %b, double %c, double %d
 ;
 ; NO-FAST-P9-LABEL: select_fast_ole_double:
 ; NO-FAST-P9:       # %bb.0: # %entry
-; NO-FAST-P9-NEXT:    xssubdp f0, f2, f1
-; NO-FAST-P9-NEXT:    fsel f1, f0, f3, f4
+; NO-FAST-P9-NEXT:    xscmpudp cr0, f1, f2
+; NO-FAST-P9-NEXT:    ble cr0, .LBB23_2
+; NO-FAST-P9-NEXT:  # %bb.1: # %entry
+; NO-FAST-P9-NEXT:    fmr f3, f4
+; NO-FAST-P9-NEXT:  .LBB23_2: # %entry
+; NO-FAST-P9-NEXT:    fmr f1, f3
 ; NO-FAST-P9-NEXT:    blr
 entry:
   %cmp = fcmp fast ole double %a, %b


        


More information about the llvm-commits mailing list