[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp

Chris Lattner sabre at nondot.org
Wed Oct 4 21:11:40 PDT 2006



Changes in directory llvm/lib/Target/X86:

X86ISelLowering.cpp updated: 1.269 -> 1.270
---
Log message:

Lower some min/max idioms to minss/maxss when unsafe fp math is enabled.


---
Diffs of the changes:  (+43 -13)

 X86ISelLowering.cpp |   56 +++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 43 insertions(+), 13 deletions(-)


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.269 llvm/lib/Target/X86/X86ISelLowering.cpp:1.270
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.269	Wed Oct  4 13:33:38 2006
+++ llvm/lib/Target/X86/X86ISelLowering.cpp	Wed Oct  4 23:11:26 2006
@@ -5377,25 +5377,55 @@
       
       unsigned IntNo = 0;
       if (LHS == Cond.getOperand(0) && RHS == Cond.getOperand(1)) {
-        // (X olt Y) ? X : Y -> min
-        if (CC == ISD::SETOLT || CC == ISD::SETLT)
+        switch (CC) {
+        default: break;
+        case ISD::SETOLE: // (X <= Y) ? X : Y -> min
+        case ISD::SETULE:
+        case ISD::SETLE:
+          if (!UnsafeFPMath) break;
+          // FALL THROUGH.
+        case ISD::SETOLT:  // (X olt/lt Y) ? X : Y -> min
+        case ISD::SETLT:
           IntNo = LHS.getValueType() == MVT::f32 ? Intrinsic::x86_sse_min_ss :
                                                    Intrinsic::x86_sse2_min_sd;
-        // (X uge Y) ? X : Y -> max
-        if (CC == ISD::SETUGE || CC == ISD::SETGE)
+          break;
+          
+        case ISD::SETOGT: // (X > Y) ? X : Y -> max
+        case ISD::SETUGT:
+        case ISD::SETGT:
+          if (!UnsafeFPMath) break;
+          // FALL THROUGH.
+        case ISD::SETUGE:  // (X uge/ge Y) ? X : Y -> max
+        case ISD::SETGE:
           IntNo = LHS.getValueType() == MVT::f32 ? Intrinsic::x86_sse_max_ss :
-            Intrinsic::x86_sse2_max_sd;
-        // TODO: Handle more cases if unsafe math!
+                                                   Intrinsic::x86_sse2_max_sd;
+          break;
+        }
       } else if (LHS == Cond.getOperand(1) && RHS == Cond.getOperand(0)) {
-        // (X uge Y) ? Y : X -> min
-        if (CC == ISD::SETUGE || CC == ISD::SETGE)
+        switch (CC) {
+        default: break;
+        case ISD::SETOGT: // (X > Y) ? Y : X -> min
+        case ISD::SETUGT:
+        case ISD::SETGT:
+          if (!UnsafeFPMath) break;
+          // FALL THROUGH.
+        case ISD::SETUGE:  // (X uge/ge Y) ? Y : X -> min
+        case ISD::SETGE:
           IntNo = LHS.getValueType() == MVT::f32 ? Intrinsic::x86_sse_min_ss :
-            Intrinsic::x86_sse2_min_sd;
-        // (X olt Y) ? Y : X -> max
-        if (CC == ISD::SETOLT || CC == ISD::SETLT)
+                                                   Intrinsic::x86_sse2_min_sd;
+          break;
+          
+        case ISD::SETOLE:   // (X <= Y) ? Y : X -> max
+        case ISD::SETULE:
+        case ISD::SETLE:
+          if (!UnsafeFPMath) break;
+          // FALL THROUGH.
+        case ISD::SETOLT:   // (X olt/lt Y) ? Y : X -> max
+        case ISD::SETLT:
           IntNo = LHS.getValueType() == MVT::f32 ? Intrinsic::x86_sse_max_ss :
-            Intrinsic::x86_sse2_max_sd;
-        // TODO: Handle more cases if unsafe math!
+                                                   Intrinsic::x86_sse2_max_sd;
+          break;
+        }
       }
       
       // minss/maxss take a v4f32 operand.






More information about the llvm-commits mailing list