mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
Extend (truncate (load)) folding
DAGCombiner could fold (truncate (load)) -> smaller load if the original load was the width of the truncation result or wider. This patch extends it to handle cases where the original load was narrower (and so the extension type stays the same). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197030 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -5632,6 +5632,20 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
|
||||
SDValue Reduced = ReduceLoadWidth(N);
|
||||
if (Reduced.getNode())
|
||||
return Reduced;
|
||||
// Handle the case where the load remains an extending load even
|
||||
// after truncation.
|
||||
if (N0.hasOneUse() && ISD::isUNINDEXEDLoad(N0.getNode())) {
|
||||
LoadSDNode *LN0 = cast<LoadSDNode>(N0);
|
||||
if (!LN0->isVolatile() &&
|
||||
LN0->getMemoryVT().getStoreSizeInBits() < VT.getSizeInBits()) {
|
||||
SDValue NewLoad = DAG.getExtLoad(LN0->getExtensionType(), SDLoc(LN0),
|
||||
VT, LN0->getChain(), LN0->getBasePtr(),
|
||||
LN0->getMemoryVT(),
|
||||
LN0->getMemOperand());
|
||||
DAG.ReplaceAllUsesOfValueWith(N0.getValue(1), NewLoad.getValue(1));
|
||||
return NewLoad;
|
||||
}
|
||||
}
|
||||
}
|
||||
// fold (trunc (concat ... x ...)) -> (concat ..., (trunc x), ...)),
|
||||
// where ... are all 'undef'.
|
||||
|
Reference in New Issue
Block a user