mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 17:24:48 +00:00
Add checks to make sure we don't create bogus extend nodes, and fix a bug
where we were doing exactly that which was causing failures on x86 and alpha. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26284 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -665,6 +665,9 @@ SDOperand DAGCombiner::visitADD(SDNode *N) {
|
|||||||
// fold (A+(B-A)) -> B
|
// fold (A+(B-A)) -> B
|
||||||
if (N1.getOpcode() == ISD::SUB && N0 == N1.getOperand(1))
|
if (N1.getOpcode() == ISD::SUB && N0 == N1.getOperand(1))
|
||||||
return N1.getOperand(0);
|
return N1.getOperand(0);
|
||||||
|
//
|
||||||
|
if (SimplifyDemandedBits(SDOperand(N, 0)))
|
||||||
|
return SDOperand();
|
||||||
return SDOperand();
|
return SDOperand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2297,13 +2300,16 @@ SDOperand DAGCombiner::SimplifySelectCC(SDOperand N0, SDOperand N1,
|
|||||||
// Get a SetCC of the condition
|
// Get a SetCC of the condition
|
||||||
// FIXME: Should probably make sure that setcc is legal if we ever have a
|
// FIXME: Should probably make sure that setcc is legal if we ever have a
|
||||||
// target where it isn't.
|
// target where it isn't.
|
||||||
SDOperand Temp, SCC = DAG.getSetCC(TLI.getSetCCResultTy(), N0, N1, CC);
|
SDOperand Temp, SCC;
|
||||||
WorkList.push_back(SCC.Val);
|
|
||||||
// cast from setcc result type to select result type
|
// cast from setcc result type to select result type
|
||||||
if (AfterLegalize)
|
if (AfterLegalize) {
|
||||||
|
SCC = DAG.getSetCC(TLI.getSetCCResultTy(), N0, N1, CC);
|
||||||
Temp = DAG.getZeroExtendInReg(SCC, N2.getValueType());
|
Temp = DAG.getZeroExtendInReg(SCC, N2.getValueType());
|
||||||
else
|
} else {
|
||||||
|
SCC = DAG.getSetCC(MVT::i1, N0, N1, CC);
|
||||||
Temp = DAG.getNode(ISD::ZERO_EXTEND, N2.getValueType(), SCC);
|
Temp = DAG.getNode(ISD::ZERO_EXTEND, N2.getValueType(), SCC);
|
||||||
|
}
|
||||||
|
WorkList.push_back(SCC.Val);
|
||||||
WorkList.push_back(Temp.Val);
|
WorkList.push_back(Temp.Val);
|
||||||
// shl setcc result by log2 n2c
|
// shl setcc result by log2 n2c
|
||||||
return DAG.getNode(ISD::SHL, N2.getValueType(), Temp,
|
return DAG.getNode(ISD::SHL, N2.getValueType(), Temp,
|
||||||
|
@ -1047,22 +1047,26 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
|
|||||||
return Operand; // Factor of one node? No factor.
|
return Operand; // Factor of one node? No factor.
|
||||||
case ISD::SIGN_EXTEND:
|
case ISD::SIGN_EXTEND:
|
||||||
if (Operand.getValueType() == VT) return Operand; // noop extension
|
if (Operand.getValueType() == VT) return Operand; // noop extension
|
||||||
|
assert(Operand.getValueType() < VT && "Invalid sext node, dst < src!");
|
||||||
if (OpOpcode == ISD::SIGN_EXTEND || OpOpcode == ISD::ZERO_EXTEND)
|
if (OpOpcode == ISD::SIGN_EXTEND || OpOpcode == ISD::ZERO_EXTEND)
|
||||||
return getNode(OpOpcode, VT, Operand.Val->getOperand(0));
|
return getNode(OpOpcode, VT, Operand.Val->getOperand(0));
|
||||||
break;
|
break;
|
||||||
case ISD::ZERO_EXTEND:
|
case ISD::ZERO_EXTEND:
|
||||||
if (Operand.getValueType() == VT) return Operand; // noop extension
|
if (Operand.getValueType() == VT) return Operand; // noop extension
|
||||||
|
assert(Operand.getValueType() < VT && "Invalid zext node, dst < src!");
|
||||||
if (OpOpcode == ISD::ZERO_EXTEND) // (zext (zext x)) -> (zext x)
|
if (OpOpcode == ISD::ZERO_EXTEND) // (zext (zext x)) -> (zext x)
|
||||||
return getNode(ISD::ZERO_EXTEND, VT, Operand.Val->getOperand(0));
|
return getNode(ISD::ZERO_EXTEND, VT, Operand.Val->getOperand(0));
|
||||||
break;
|
break;
|
||||||
case ISD::ANY_EXTEND:
|
case ISD::ANY_EXTEND:
|
||||||
if (Operand.getValueType() == VT) return Operand; // noop extension
|
if (Operand.getValueType() == VT) return Operand; // noop extension
|
||||||
|
assert(Operand.getValueType() < VT && "Invalid anyext node, dst < src!");
|
||||||
if (OpOpcode == ISD::ZERO_EXTEND || OpOpcode == ISD::SIGN_EXTEND)
|
if (OpOpcode == ISD::ZERO_EXTEND || OpOpcode == ISD::SIGN_EXTEND)
|
||||||
// (ext (zext x)) -> (zext x) and (ext (sext x)) -> (sext x)
|
// (ext (zext x)) -> (zext x) and (ext (sext x)) -> (sext x)
|
||||||
return getNode(OpOpcode, VT, Operand.Val->getOperand(0));
|
return getNode(OpOpcode, VT, Operand.Val->getOperand(0));
|
||||||
break;
|
break;
|
||||||
case ISD::TRUNCATE:
|
case ISD::TRUNCATE:
|
||||||
if (Operand.getValueType() == VT) return Operand; // noop truncate
|
if (Operand.getValueType() == VT) return Operand; // noop truncate
|
||||||
|
assert(Operand.getValueType() > VT && "Invalid truncate node, src < dst!");
|
||||||
if (OpOpcode == ISD::TRUNCATE)
|
if (OpOpcode == ISD::TRUNCATE)
|
||||||
return getNode(ISD::TRUNCATE, VT, Operand.Val->getOperand(0));
|
return getNode(ISD::TRUNCATE, VT, Operand.Val->getOperand(0));
|
||||||
else if (OpOpcode == ISD::ZERO_EXTEND || OpOpcode == ISD::SIGN_EXTEND ||
|
else if (OpOpcode == ISD::ZERO_EXTEND || OpOpcode == ISD::SIGN_EXTEND ||
|
||||||
|
Reference in New Issue
Block a user