aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2007-07-10 14:20:37 +0000
committerDan Gohman <gohman@apple.com>2007-07-10 14:20:37 +0000
commitd595b5f1f051d79764ac8469f02efaae398f115c (patch)
tree4421d34ac2a68f7348bbb9cbff8c2e2f920630dc /lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent087d90e9124ee79b88a96c950730f07ad281ed06 (diff)
Fix the folding of undef in several binary operators to recognize
undef in either the left or right operand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38489 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 81d5757d9d..861e5056bb 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -855,7 +855,7 @@ SDOperand DAGCombiner::visitADD(SDNode *N) {
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 @@ SDOperand DAGCombiner::visitMUL(SDNode *N) {
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 @@ SDOperand DAGCombiner::visitMULHS(SDNode *N) {
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 @@ SDOperand DAGCombiner::visitMULHU(SDNode *N) {
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 @@ SDOperand DAGCombiner::visitAND(SDNode *N) {
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 @@ SDOperand DAGCombiner::visitOR(SDNode *N) {
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 @@ SDOperand DAGCombiner::visitXOR(SDNode *N) {
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)