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

Dan Gohman djg at cray.com
Tue Jul 10 08:19:30 PDT 2007


Author: djg
Date: Tue Jul 10 10:19:29 2007
New Revision: 38491

URL: http://llvm.org/viewvc/llvm-project?rev=38491&view=rev
Log:
Fix a bug in the folding of binary operators to undef.
Thanks to Lauro for spotting this!

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=38491&r1=38490&r2=38491&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Jul 10 10:19:29 2007
@@ -855,7 +855,9 @@
   if (FoldedVOp.Val) return FoldedVOp;
   
   // fold (add x, undef) -> undef
-  if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
+  if (N0.getOpcode() == ISD::UNDEF)
+    return N0;
+  if (N1.getOpcode() == ISD::UNDEF)
     return N1;
   // fold (add c1, c2) -> c1+c2
   if (N0C && N1C)
@@ -1029,8 +1031,10 @@
     if (Result.Val) return Result;
   }
   // If either operand of a sub is undef, the result is undef
-  if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
-    return DAG.getNode(ISD::UNDEF, VT);
+  if (N0.getOpcode() == ISD::UNDEF)
+    return N0;
+  if (N1.getOpcode() == ISD::UNDEF)
+    return N1;
 
   return SDOperand();
 }
@@ -1890,7 +1894,9 @@
   if (FoldedVOp.Val) return FoldedVOp;
   
   // fold (xor x, undef) -> undef
-  if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
+  if (N0.getOpcode() == ISD::UNDEF)
+    return N0;
+  if (N1.getOpcode() == ISD::UNDEF)
     return N1;
   // fold (xor c1, c2) -> c1^c2
   if (N0C && N1C)





More information about the llvm-commits mailing list