mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-28 06:58:19 +00:00
fold (sra (sra x, c1), c2) -> (sra x, c1+c2)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26416 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9794392781
commit
71d9ebcbc1
@ -23,9 +23,6 @@
|
|||||||
// FIXME: mul (x, const) -> shifts + adds
|
// FIXME: mul (x, const) -> shifts + adds
|
||||||
// FIXME: undef values
|
// FIXME: undef values
|
||||||
// FIXME: make truncate see through SIGN_EXTEND and AND
|
// FIXME: make truncate see through SIGN_EXTEND and AND
|
||||||
// FIXME: (sra (sra x, c1), c2) -> (sra x, c1+c2)
|
|
||||||
// FIXME: verify that getNode can't return extends with an operand whose type
|
|
||||||
// is >= to that of the extend.
|
|
||||||
// FIXME: divide by zero is currently left unfolded. do we want to turn this
|
// FIXME: divide by zero is currently left unfolded. do we want to turn this
|
||||||
// into an undef?
|
// into an undef?
|
||||||
// FIXME: select ne (select cc, 1, 0), 0, true, false -> select cc, true, false
|
// FIXME: select ne (select cc, 1, 0), 0, true, false -> select cc, true, false
|
||||||
@ -1367,6 +1364,17 @@ SDOperand DAGCombiner::visitSRA(SDNode *N) {
|
|||||||
return DAG.getNode(ISD::SIGN_EXTEND_INREG, VT, N0.getOperand(0),
|
return DAG.getNode(ISD::SIGN_EXTEND_INREG, VT, N0.getOperand(0),
|
||||||
DAG.getValueType(EVT));
|
DAG.getValueType(EVT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fold (sra (sra x, c1), c2) -> (sra x, c1+c2)
|
||||||
|
if (N1C && N0.getOpcode() == ISD::SRA) {
|
||||||
|
if (ConstantSDNode *C1 = dyn_cast<ConstantSDNode>(N0.getOperand(1))) {
|
||||||
|
unsigned Sum = N1C->getValue() + C1->getValue();
|
||||||
|
if (Sum >= MVT::getSizeInBits(VT)) Sum = MVT::getSizeInBits(VT)-1;
|
||||||
|
return DAG.getNode(ISD::SRA, VT, N0.getOperand(0),
|
||||||
|
DAG.getConstant(Sum, N1C->getValueType(0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If the sign bit is known to be zero, switch this to a SRL.
|
// If the sign bit is known to be zero, switch this to a SRL.
|
||||||
if (TLI.MaskedValueIsZero(N0, MVT::getIntVTSignBit(VT)))
|
if (TLI.MaskedValueIsZero(N0, MVT::getIntVTSignBit(VT)))
|
||||||
return DAG.getNode(ISD::SRL, VT, N0, N1);
|
return DAG.getNode(ISD::SRL, VT, N0, N1);
|
||||||
|
Loading…
Reference in New Issue
Block a user