diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -7582,7 +7582,8 @@ 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 --- a/llvm/test/CodeGen/PowerPC/scalar-equal.ll +++ b/llvm/test/CodeGen/PowerPC/scalar-equal.ll @@ -35,10 +35,12 @@ ; ; 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 --- a/llvm/test/CodeGen/PowerPC/scalar_cmp.ll +++ b/llvm/test/CodeGen/PowerPC/scalar_cmp.ll @@ -127,10 +127,12 @@ ; ; 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 @@ ; ; 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 @@ ; ; 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 @@ ; ; 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 @@ ; ; 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 @@ ; ; 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 @@ ; ; 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 @@ ; ; 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 @@ ; ; 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 @@ ; ; 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 @@ ; ; 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 @@ ; ; 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