[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Aug 9 16:09:16 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAG.cpp updated: 1.131 -> 1.132
---
Log message:

Fix spelling, fix some broken canonicalizations by my last patch


---
Diffs of the changes:  (+11 -12)

 SelectionDAG.cpp |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.131 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.132
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.131	Tue Aug  9 15:40:02 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Tue Aug  9 18:09:05 2005
@@ -386,8 +386,8 @@
   return SDOperand(CondCodeNodes[Cond], 0);
 }
 
-SDOperand SelectionDAG::SimplfySetCC(MVT::ValueType VT, SDOperand N1,
-                                     SDOperand N2, ISD::CondCode Cond) {
+SDOperand SelectionDAG::SimplifySetCC(MVT::ValueType VT, SDOperand N1,
+                                      SDOperand N2, ISD::CondCode Cond) {
   // These setcc operations always fold.
   switch (Cond) {
   default: break;
@@ -484,17 +484,15 @@
       if (Cond == ISD::SETGE || Cond == ISD::SETUGE) {
         if (C2 == MinVal) return getConstant(1, VT);   // X >= MIN --> true
         --C2;                                          // X >= C1 --> X > (C1-1)
-        Cond = (Cond == ISD::SETGE) ? ISD::SETGT : ISD::SETUGT;
-        N2 = getConstant(C2, N2.getValueType());
-        N2C = cast<ConstantSDNode>(N2.Val);
+        return getSetCC(VT, N1, getConstant(C2, N2.getValueType()),
+                        (Cond == ISD::SETGE) ? ISD::SETGT : ISD::SETUGT);
       }
 
       if (Cond == ISD::SETLE || Cond == ISD::SETULE) {
         if (C2 == MaxVal) return getConstant(1, VT);   // X <= MAX --> true
         ++C2;                                          // X <= C1 --> X < (C1+1)
-        Cond = (Cond == ISD::SETLE) ? ISD::SETLT : ISD::SETULT;
-        N2 = getConstant(C2, N2.getValueType());
-        N2C = cast<ConstantSDNode>(N2.Val);
+        return getSetCC(VT, N1, getConstant(C2, N2.getValueType()),
+                        (Cond == ISD::SETLE) ? ISD::SETLT : ISD::SETULT);
       }
 
       if ((Cond == ISD::SETLT || Cond == ISD::SETULT) && C2 == MinVal)
@@ -566,8 +564,7 @@
       }
     } else {
       // Ensure that the constant occurs on the RHS.
-      Cond = ISD::getSetCCSwappedOperands(Cond);
-      std::swap(N1, N2);
+      return getSetCC(VT, N2, N1, ISD::getSetCCSwappedOperands(Cond));
     }
 
   if (N1 == N2) {
@@ -581,7 +578,9 @@
       return getConstant(UOF, VT);
     // Otherwise, we can't fold it.  However, we can simplify it to SETUO/SETO
     // if it is not already.
-    Cond = UOF == 0 ? ISD::SETUO : ISD::SETO;
+    ISD::CondCode NewCond = UOF == 0 ? ISD::SETUO : ISD::SETO;
+    if (NewCond != Cond)
+      return getSetCC(VT, N1, N2, NewCond);
   }
 
   if ((Cond == ISD::SETEQ || Cond == ISD::SETNE) &&
@@ -1356,7 +1355,7 @@
   switch (Opcode) {
   case ISD::SETCC: {
     // Use SimplifySetCC  to simplify SETCC's.
-    SDOperand Simp = SimplfySetCC(VT, N1, N2, cast<CondCodeSDNode>(N3)->get());
+    SDOperand Simp = SimplifySetCC(VT, N1, N2, cast<CondCodeSDNode>(N3)->get());
     if (Simp.Val) return Simp;
     break;
   }






More information about the llvm-commits mailing list