aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2007-07-10 15:19:29 +0000
committerDan Gohman <gohman@apple.com>2007-07-10 15:19:29 +0000
commit70fb1aefd58eb78404a2bc86b6960b7b64574082 (patch)
tree7b4e8205aae2642676e6896f5a640df165b0cc18 /lib/CodeGen
parenteff155349acd73e555a81e7935a9ec4f48ea2bb5 (diff)
Fix a bug in the folding of binary operators to undef.
Thanks to Lauro for spotting this! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38491 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 861e5056bb..e0f0ece9cd 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -855,7 +855,9 @@ SDOperand DAGCombiner::visitADD(SDNode *N) {
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 @@ SDOperand DAGCombiner::visitSUB(SDNode *N) {
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 @@ SDOperand DAGCombiner::visitXOR(SDNode *N) {
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)