mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-19 04:29:21 +00:00
A couple of bug fixes for reducing load width xform:
1. Address offset is in bytes. 2. Make sure truncate node uses are replaced with new load. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35274 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a03d45fa88
commit
0b063def98
@ -2017,8 +2017,11 @@ SDOperand DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
|
||||
// fold (sext (truncate (srl (load x), c))) -> (sext (smaller load (x+c/n)))
|
||||
if (N0.getOpcode() == ISD::TRUNCATE) {
|
||||
SDOperand NarrowLoad = ReduceLoadWidth(N0.Val);
|
||||
if (NarrowLoad.Val)
|
||||
N0 = NarrowLoad;
|
||||
if (NarrowLoad.Val) {
|
||||
if (NarrowLoad.Val != N0.Val)
|
||||
CombineTo(N0.Val, NarrowLoad);
|
||||
return DAG.getNode(ISD::SIGN_EXTEND, VT, NarrowLoad);
|
||||
}
|
||||
}
|
||||
|
||||
// See if the value being truncated is already sign extended. If so, just
|
||||
@ -2109,8 +2112,11 @@ SDOperand DAGCombiner::visitZERO_EXTEND(SDNode *N) {
|
||||
// fold (zext (truncate (srl (load x), c))) -> (zext (small load (x+c/n)))
|
||||
if (N0.getOpcode() == ISD::TRUNCATE) {
|
||||
SDOperand NarrowLoad = ReduceLoadWidth(N0.Val);
|
||||
if (NarrowLoad.Val)
|
||||
N0 = NarrowLoad;
|
||||
if (NarrowLoad.Val) {
|
||||
if (NarrowLoad.Val != N0.Val)
|
||||
CombineTo(N0.Val, NarrowLoad);
|
||||
return DAG.getNode(ISD::ZERO_EXTEND, VT, NarrowLoad);
|
||||
}
|
||||
}
|
||||
|
||||
// fold (zext (truncate x)) -> (and x, mask)
|
||||
@ -2189,8 +2195,11 @@ SDOperand DAGCombiner::visitANY_EXTEND(SDNode *N) {
|
||||
// fold (aext (truncate (srl (load x), c))) -> (aext (small load (x+c/n)))
|
||||
if (N0.getOpcode() == ISD::TRUNCATE) {
|
||||
SDOperand NarrowLoad = ReduceLoadWidth(N0.Val);
|
||||
if (NarrowLoad.Val)
|
||||
N0 = NarrowLoad;
|
||||
if (NarrowLoad.Val) {
|
||||
if (NarrowLoad.Val != N0.Val)
|
||||
CombineTo(N0.Val, NarrowLoad);
|
||||
return DAG.getNode(ISD::ANY_EXTEND, VT, NarrowLoad);
|
||||
}
|
||||
}
|
||||
|
||||
// fold (aext (truncate x))
|
||||
@ -2278,7 +2287,7 @@ SDOperand DAGCombiner::ReduceLoadWidth(SDNode *N) {
|
||||
N0 = N0.getOperand(0);
|
||||
if (MVT::getSizeInBits(N0.getValueType()) <= EVTBits)
|
||||
return SDOperand();
|
||||
ShAmt /= EVTBits;
|
||||
ShAmt /= 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user