mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +00:00
Revert "Revert '[DAGCombiner] Split up an indexed load if only the base pointer value is live'"
I reverted r208640 in r209747 because r208640 broke self-hosting on PPC64. The underlying cause of the failure is that pre-inc loads with increments represented by ISD::TargetConstants were being transformed into ISD:::ADDs with ISD::TargetConstant operands. PPC doesn't have a pattern for those, and so they were selected as invalid r+r adds. This recommits r208640, rebased and with an exclusion for ISD::TargetConstant increments. This behavior seems correct, although in the future we might want to ask the target to split out the indexing that uses ISD::TargetConstants. Unfortunately, I don't yet have small test case where the relevant invalid 'add' instruction is not itself dead (and thus eliminated by DeadMachineInstructionElim -- sometimes bugpoint is too good at removing things) Original commit message (by Adam Nemet): Right now the load may not get DCE'd because of the side-effect of updating the base pointer. This can happen if we lower a read-modify-write of an illegal larger type (e.g. i48) such that the modification only affects one of the subparts (the lower i32 part but not the higher i16 part). See the testcase. In order to spot the dead load we need to revisit it when SimplifyDemandedBits decided that the value of the load is masked off. This is the CommitTargetLoweringOpt piece. I checked compile time with ARM64 by sending SPEC bitcode files through llc. No measurable change. Fixes <rdar://problem/16031651> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216898 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dea837d3c5
commit
3da41a28a1
@ -77,6 +77,10 @@ namespace {
|
||||
"slicing"),
|
||||
cl::init(false));
|
||||
|
||||
static cl::opt<bool>
|
||||
MaySplitLoadIndex("combiner-split-load-index", cl::Hidden, cl::init(true),
|
||||
cl::desc("DAG combiner may split indexing from loads"));
|
||||
|
||||
//------------------------------ DAGCombiner ---------------------------------//
|
||||
|
||||
class DAGCombiner {
|
||||
@ -182,6 +186,7 @@ namespace {
|
||||
|
||||
bool CombineToPreIndexedLoadStore(SDNode *N);
|
||||
bool CombineToPostIndexedLoadStore(SDNode *N);
|
||||
SDValue SplitIndexingFromLoad(LoadSDNode *LD);
|
||||
bool SliceUpLoad(SDNode *N);
|
||||
|
||||
/// \brief Replace an ISD::EXTRACT_VECTOR_ELT of a load with a narrowed
|
||||
@ -462,7 +467,10 @@ void DAGCombiner::deleteAndRecombine(SDNode *N) {
|
||||
// If the operands of this node are only used by the node, they will now be
|
||||
// dead. Make sure to re-visit them and recursively delete dead nodes.
|
||||
for (const SDValue &Op : N->ops())
|
||||
if (Op->hasOneUse())
|
||||
// For an operand generating multiple values, one of the values may
|
||||
// become dead allowing further simplification (e.g. split index
|
||||
// arithmetic from an indexed load).
|
||||
if (Op->hasOneUse() || Op->getNumValues() > 1)
|
||||
AddToWorklist(Op.getNode());
|
||||
|
||||
DAG.DeleteNode(N);
|
||||
@ -8015,6 +8023,19 @@ bool DAGCombiner::CombineToPostIndexedLoadStore(SDNode *N) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// \brief Return the base-pointer arithmetic from an indexed \p LD.
|
||||
SDValue DAGCombiner::SplitIndexingFromLoad(LoadSDNode *LD) {
|
||||
ISD::MemIndexedMode AM = LD->getAddressingMode();
|
||||
assert(AM != ISD::UNINDEXED);
|
||||
SDValue BP = LD->getOperand(1);
|
||||
SDValue Inc = LD->getOperand(2);
|
||||
assert(Inc.getOpcode() != ISD::TargetConstant &&
|
||||
"Cannot split out indexing using target constants");
|
||||
unsigned Opc =
|
||||
(AM == ISD::PRE_INC || AM == ISD::POST_INC ? ISD::ADD : ISD::SUB);
|
||||
return DAG.getNode(Opc, SDLoc(LD), BP.getSimpleValueType(), BP, Inc);
|
||||
}
|
||||
|
||||
SDValue DAGCombiner::visitLOAD(SDNode *N) {
|
||||
LoadSDNode *LD = cast<LoadSDNode>(N);
|
||||
SDValue Chain = LD->getChain();
|
||||
@ -8049,8 +8070,23 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
|
||||
} else {
|
||||
// Indexed loads.
|
||||
assert(N->getValueType(2) == MVT::Other && "Malformed indexed loads?");
|
||||
if (!N->hasAnyUseOfValue(0) && !N->hasAnyUseOfValue(1)) {
|
||||
|
||||
// If this load has an TargetConstant offset, then we cannot split the
|
||||
// indexing into an add/sub directly (that TargetConstant may not be
|
||||
// valid for a different type of node).
|
||||
bool HasTCInc = LD->getOperand(2).getOpcode() == ISD::TargetConstant;
|
||||
|
||||
if (!N->hasAnyUseOfValue(0) &&
|
||||
((MaySplitLoadIndex && !HasTCInc) || !N->hasAnyUseOfValue(1))) {
|
||||
SDValue Undef = DAG.getUNDEF(N->getValueType(0));
|
||||
SDValue Index;
|
||||
if (N->hasAnyUseOfValue(1) && MaySplitLoadIndex && !HasTCInc) {
|
||||
Index = SplitIndexingFromLoad(LD);
|
||||
// Try to fold the base pointer arithmetic into subsequent loads and
|
||||
// stores.
|
||||
AddUsersToWorklist(N);
|
||||
} else
|
||||
Index = DAG.getUNDEF(N->getValueType(1));
|
||||
DEBUG(dbgs() << "\nReplacing.7 ";
|
||||
N->dump(&DAG);
|
||||
dbgs() << "\nWith: ";
|
||||
@ -8058,8 +8094,7 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
|
||||
dbgs() << " and 2 other values\n");
|
||||
WorklistRemover DeadNodes(*this);
|
||||
DAG.ReplaceAllUsesOfValueWith(SDValue(N, 0), Undef);
|
||||
DAG.ReplaceAllUsesOfValueWith(SDValue(N, 1),
|
||||
DAG.getUNDEF(N->getValueType(1)));
|
||||
DAG.ReplaceAllUsesOfValueWith(SDValue(N, 1), Index);
|
||||
DAG.ReplaceAllUsesOfValueWith(SDValue(N, 2), Chain);
|
||||
deleteAndRecombine(N);
|
||||
return SDValue(N, 0); // Return N so it doesn't get rechecked!
|
||||
|
@ -1,8 +1,4 @@
|
||||
; RUN: llc -mcpu=cyclone < %s | FileCheck %s
|
||||
|
||||
; r208640 broke ppc64/Linux self-hosting; xfailing while this is worked on.
|
||||
; XFAIL: *
|
||||
|
||||
target datalayout = "e-i64:64-n32:64-S128"
|
||||
target triple = "arm64-apple-ios"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user