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

Nate Begeman natebegeman at mac.com
Mon Aug 22 22:41:24 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAG.cpp updated: 1.156 -> 1.157
---
Log message:

Teach the SelectionDAG how to transform select_cc eq, X, 0, 1, 0 into 
either seteq X, 0 or srl (ctlz X), size(X-1), depending on what's legal
for the target.


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

 SelectionDAG.cpp |   17 +++++++++++++++++
 1 files changed, 17 insertions(+)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.156 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.157
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.156	Sun Aug 21 17:30:30 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Tue Aug 23 00:41:12 2005
@@ -853,6 +853,23 @@
     }
   }
   
+  // Check to see if this is the equivalent of seteq X, 0.
+  // select_cc seteq X, 0, 1, 0 -> setcc X, 0, seteq -> srl (ctlz X), size(X)-1
+  if (N2C && N2C->isNullValue() && N4C && N4C->isNullValue() &&
+      N3C && (N3C->getValue() == 1)) {
+    MVT::ValueType XType = N1.getValueType();
+    if (TLI.getOperationAction(ISD::SETCC, TLI.getSetCCResultTy()) == 
+        TargetLowering::Legal) {
+      return getSetCC(TLI.getSetCCResultTy(), N1, N2, ISD::SETEQ);
+    }
+    if (TLI.getOperationAction(ISD::CTLZ, XType) == TargetLowering::Legal) {
+      SDOperand Ctlz = getNode(ISD::CTLZ, XType, N1);
+      return getNode(ISD::SRL, XType, Ctlz, 
+                     getConstant(MVT::getSizeInBits(XType)-1,
+                                 TLI.getShiftAmountTy()));
+    }
+  }
+
   // Check to see if this is an integer abs. select_cc setl[te] X, 0, -X, X ->
   // Y = sra (X, size(X)-1); xor (add (X, Y), Y)
   if (N2C && N2C->isNullValue() && (CC == ISD::SETLT || CC == ISD::SETLE) &&






More information about the llvm-commits mailing list