[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Aug 26 11:47:01 PDT 2005



Changes in directory llvm/lib/Target/PowerPC:

PPC32ISelDAGToDAG.cpp updated: 1.42 -> 1.43
---
Log message:

implement the fold for:

bool %test(int %X, int %Y) {
        %C = setne int %X, 0
        ret bool %C
}

to:

_test:
        addic r2, r3, -1
        subfe r3, r2, r3
        blr



---
Diffs of the changes:  (+21 -0)

 PPC32ISelDAGToDAG.cpp |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+)


Index: llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp
diff -u llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.42 llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.43
--- llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.42	Fri Aug 26 13:37:23 2005
+++ llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp	Fri Aug 26 13:46:49 2005
@@ -1376,6 +1376,27 @@
     break;
   }
 
+  case ISD::SELECT_CC: {
+    ISD::CondCode CC = cast<CondCodeSDNode>(N->getOperand(4))->get();
+    
+    // handle the setcc cases here.  select_cc lhs, 0, 1, 0, cc
+    if (ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N->getOperand(1)))
+      if (ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N->getOperand(2)))
+        if (ConstantSDNode *N3C = dyn_cast<ConstantSDNode>(N->getOperand(3)))
+          if (N1C->isNullValue() && N3C->isNullValue() &&
+              N2C->getValue() == 1ULL && CC == ISD::SETNE) {
+            SDOperand LHS = Select(N->getOperand(0));
+            SDOperand Tmp =
+              CurDAG->getTargetNode(PPC::ADDIC, MVT::i32, MVT::Flag,
+                                    LHS, getI32Imm(~0U));
+            CurDAG->SelectNodeTo(N, PPC::SUBFE, MVT::i32, Tmp, LHS,
+                                 Tmp.getValue(1));
+            break;
+          }
+    
+    assert(0 && "Select_cc not implemented yet!");
+  }
+    
   case ISD::CALLSEQ_START:
   case ISD::CALLSEQ_END: {
     unsigned Amt = cast<ConstantSDNode>(N->getOperand(1))->getValue();






More information about the llvm-commits mailing list