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

Chris Lattner sabre at nondot.org
Tue Sep 19 23:29:31 PDT 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

DAGCombiner.cpp updated: 1.188 -> 1.189
---
Log message:

Fold the full generality of (any_extend (truncate x))


---
Diffs of the changes:  (+9 -3)

 DAGCombiner.cpp |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.188 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.189
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.188	Wed Sep 20 01:19:26 2006
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp	Wed Sep 20 01:29:17 2006
@@ -1858,9 +1858,15 @@
       N0.getOpcode() == ISD::SIGN_EXTEND)
     return DAG.getNode(N0.getOpcode(), VT, N0.getOperand(0));
   
-  // fold (aext (truncate x)) -> x iff x size == zext size.
-  if (N0.getOpcode() == ISD::TRUNCATE && N0.getOperand(0).getValueType() == VT)
-    return N0.getOperand(0);
+  // fold (aext (truncate x))
+  if (N0.getOpcode() == ISD::TRUNCATE) {
+    SDOperand TruncOp = N0.getOperand(0);
+    if (TruncOp.getValueType() == VT)
+      return TruncOp; // x iff x size == zext size.
+    if (TruncOp.getValueType() > VT)
+      return DAG.getNode(ISD::TRUNCATE, VT, TruncOp);
+    return DAG.getNode(ISD::ANY_EXTEND, VT, TruncOp);
+  }
   // fold (aext (load x)) -> (aext (truncate (extload x)))
   if (N0.getOpcode() == ISD::LOAD && N0.hasOneUse() &&
       (!AfterLegalize||TLI.isOperationLegal(ISD::EXTLOAD, N0.getValueType()))) {






More information about the llvm-commits mailing list