summaryrefslogtreecommitdiffstats
path: root/llvm/lib
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
commitadb3d37c07bf4c7911498301af122a260c6da89f (patch)
tree5c5037280d3056a5e7b1375734890b7126d138e3 /llvm/lib
parentbca08114624a046f3c67652d1361121614bce347 (diff)
downloadbcm5719-llvm-adb3d37c07bf4c7911498301af122a260c6da89f.tar.gz
bcm5719-llvm-adb3d37c07bf4c7911498301af122a260c6da89f.zip
Fix a bug in the folding of binary operators to undef.
Thanks to Lauro for spotting this! llvm-svn: 38491
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 861e5056bb4..e0f0ece9cd5 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/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)
OpenPOWER on IntegriCloud