[llvm-commits] [llvm] r38489 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Dan Gohman djg at cray.com
Tue Jul 10 07:20:38 PDT 2007


Author: djg
Date: Tue Jul 10 09:20:37 2007
New Revision: 38489

URL: http://llvm.org/viewvc/llvm-project?rev=38489&view=rev
Log:
Fix the folding of undef in several binary operators to recognize
undef in either the left or right operand.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=38489&r1=38488&r2=38489&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Jul 10 09:20:37 2007
@@ -855,7 +855,7 @@
   if (FoldedVOp.Val) return FoldedVOp;
   
   // fold (add x, undef) -> undef
-  if (N1.getOpcode() == ISD::UNDEF)
+  if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
     return N1;
   // fold (add c1, c2) -> c1+c2
   if (N0C && N1C)
@@ -1047,7 +1047,7 @@
   if (FoldedVOp.Val) return FoldedVOp;
   
   // fold (mul x, undef) -> 0
-  if (N1.getOpcode() == ISD::UNDEF)
+  if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
     return DAG.getConstant(0, VT);
   // fold (mul c1, c2) -> c1*c2
   if (N0C && N1C)
@@ -1339,7 +1339,7 @@
                        DAG.getConstant(MVT::getSizeInBits(N0.getValueType())-1,
                                        TLI.getShiftAmountTy()));
   // fold (mulhs x, undef) -> 0
-  if (N1.getOpcode() == ISD::UNDEF)
+  if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
     return DAG.getConstant(0, VT);
 
   return SDOperand();
@@ -1358,7 +1358,7 @@
   if (N1C && N1C->getValue() == 1)
     return DAG.getConstant(0, N0.getValueType());
   // fold (mulhu x, undef) -> 0
-  if (N1.getOpcode() == ISD::UNDEF)
+  if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
     return DAG.getConstant(0, VT);
 
   return SDOperand();
@@ -1416,7 +1416,7 @@
   if (FoldedVOp.Val) return FoldedVOp;
   
   // fold (and x, undef) -> 0
-  if (N1.getOpcode() == ISD::UNDEF)
+  if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
     return DAG.getConstant(0, VT);
   // fold (and c1, c2) -> c1&c2
   if (N0C && N1C)
@@ -1604,7 +1604,7 @@
   if (FoldedVOp.Val) return FoldedVOp;
   
   // fold (or x, undef) -> -1
-  if (N1.getOpcode() == ISD::UNDEF)
+  if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
     return DAG.getConstant(~0ULL, VT);
   // fold (or c1, c2) -> c1|c2
   if (N0C && N1C)
@@ -1890,7 +1890,7 @@
   if (FoldedVOp.Val) return FoldedVOp;
   
   // fold (xor x, undef) -> undef
-  if (N1.getOpcode() == ISD::UNDEF)
+  if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
     return N1;
   // fold (xor c1, c2) -> c1^c2
   if (N0C && N1C)





More information about the llvm-commits mailing list