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

Chris Lattner lattner at cs.uiuc.edu
Wed Mar 1 13:47:33 PST 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

DAGCombiner.cpp updated: 1.118 -> 1.119
---
Log message:

Fix CodeGen/Generic/2006-03-01-dagcombineinfloop.ll, an infinite loop
in the dag combiner on 176.gcc on x86.


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

 DAGCombiner.cpp |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.118 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.119
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.118	Wed Mar  1 13:55:35 2006
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp	Wed Mar  1 15:47:21 2006
@@ -1018,14 +1018,19 @@
         return N1;
   // fold (and (any_ext V), c) -> (zero_ext V) if 'and' only clears top bits.
   if (N1C && N0.getOpcode() == ISD::ANY_EXTEND) {
-    unsigned InBits = MVT::getSizeInBits(N0.getOperand(0).getValueType());
+    unsigned InMask = MVT::getIntVTBitMask(N0.getOperand(0).getValueType());
     if (TLI.MaskedValueIsZero(N0.getOperand(0),
-                              ~N1C->getValue() & ((1ULL << InBits)-1))) {
+                              ~N1C->getValue() & InMask)) {
+      SDOperand Zext = DAG.getNode(ISD::ZERO_EXTEND, N0.getValueType(),
+                                   N0.getOperand(0));
+      
+      // Replace uses of the AND with uses of the Zero extend node.
+      CombineTo(N, Zext);
+      
       // We actually want to replace all uses of the any_extend with the
       // zero_extend, to avoid duplicating things.  This will later cause this
       // AND to be folded.
-      CombineTo(N0.Val, DAG.getNode(ISD::ZERO_EXTEND, N0.getValueType(),
-                                    N0.getOperand(0)));
+      CombineTo(N0.Val, Zext);
       return SDOperand();
     }
   }






More information about the llvm-commits mailing list