mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-10 18:34:09 +00:00
Disable transformation of select of two loads to a select of address and then a load if the
loads are not in the default address space because the transformation discards src value info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93180 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7462b5dd99
commit
fe240b1066
@ -5792,35 +5792,48 @@ bool DAGCombiner::SimplifySelectOps(SDNode *TheSelect, SDValue LHS,
|
|||||||
if (LLD->getMemoryVT() == RLD->getMemoryVT()) {
|
if (LLD->getMemoryVT() == RLD->getMemoryVT()) {
|
||||||
// FIXME: this discards src value information. This is
|
// FIXME: this discards src value information. This is
|
||||||
// over-conservative. It would be beneficial to be able to remember
|
// over-conservative. It would be beneficial to be able to remember
|
||||||
// both potential memory locations.
|
// both potential memory locations. Since we are discarding
|
||||||
|
// src value info, don't do the transformation if the memory
|
||||||
|
// locations are not in the default address space.
|
||||||
|
unsigned LLDAddrSpace = 0, RLDAddrSpace = 0;
|
||||||
|
if (const Value *LLDVal = LLD->getMemOperand()->getValue()) {
|
||||||
|
if (const PointerType *PT = dyn_cast<PointerType>(LLDVal->getType()))
|
||||||
|
LLDAddrSpace = PT->getAddressSpace();
|
||||||
|
}
|
||||||
|
if (const Value *RLDVal = RLD->getMemOperand()->getValue()) {
|
||||||
|
if (const PointerType *PT = dyn_cast<PointerType>(RLDVal->getType()))
|
||||||
|
RLDAddrSpace = PT->getAddressSpace();
|
||||||
|
}
|
||||||
SDValue Addr;
|
SDValue Addr;
|
||||||
if (TheSelect->getOpcode() == ISD::SELECT) {
|
if (LLDAddrSpace == 0 && RLDAddrSpace == 0) {
|
||||||
// Check that the condition doesn't reach either load. If so, folding
|
if (TheSelect->getOpcode() == ISD::SELECT) {
|
||||||
// this will induce a cycle into the DAG.
|
// Check that the condition doesn't reach either load. If so, folding
|
||||||
if ((!LLD->hasAnyUseOfValue(1) ||
|
// this will induce a cycle into the DAG.
|
||||||
!LLD->isPredecessorOf(TheSelect->getOperand(0).getNode())) &&
|
if ((!LLD->hasAnyUseOfValue(1) ||
|
||||||
(!RLD->hasAnyUseOfValue(1) ||
|
!LLD->isPredecessorOf(TheSelect->getOperand(0).getNode())) &&
|
||||||
!RLD->isPredecessorOf(TheSelect->getOperand(0).getNode()))) {
|
(!RLD->hasAnyUseOfValue(1) ||
|
||||||
Addr = DAG.getNode(ISD::SELECT, TheSelect->getDebugLoc(),
|
!RLD->isPredecessorOf(TheSelect->getOperand(0).getNode()))) {
|
||||||
LLD->getBasePtr().getValueType(),
|
Addr = DAG.getNode(ISD::SELECT, TheSelect->getDebugLoc(),
|
||||||
TheSelect->getOperand(0), LLD->getBasePtr(),
|
LLD->getBasePtr().getValueType(),
|
||||||
RLD->getBasePtr());
|
TheSelect->getOperand(0), LLD->getBasePtr(),
|
||||||
}
|
RLD->getBasePtr());
|
||||||
} else {
|
}
|
||||||
// Check that the condition doesn't reach either load. If so, folding
|
} else {
|
||||||
// this will induce a cycle into the DAG.
|
// Check that the condition doesn't reach either load. If so, folding
|
||||||
if ((!LLD->hasAnyUseOfValue(1) ||
|
// this will induce a cycle into the DAG.
|
||||||
(!LLD->isPredecessorOf(TheSelect->getOperand(0).getNode()) &&
|
if ((!LLD->hasAnyUseOfValue(1) ||
|
||||||
!LLD->isPredecessorOf(TheSelect->getOperand(1).getNode()))) &&
|
(!LLD->isPredecessorOf(TheSelect->getOperand(0).getNode()) &&
|
||||||
(!RLD->hasAnyUseOfValue(1) ||
|
!LLD->isPredecessorOf(TheSelect->getOperand(1).getNode()))) &&
|
||||||
(!RLD->isPredecessorOf(TheSelect->getOperand(0).getNode()) &&
|
(!RLD->hasAnyUseOfValue(1) ||
|
||||||
!RLD->isPredecessorOf(TheSelect->getOperand(1).getNode())))) {
|
(!RLD->isPredecessorOf(TheSelect->getOperand(0).getNode()) &&
|
||||||
Addr = DAG.getNode(ISD::SELECT_CC, TheSelect->getDebugLoc(),
|
!RLD->isPredecessorOf(TheSelect->getOperand(1).getNode())))) {
|
||||||
LLD->getBasePtr().getValueType(),
|
Addr = DAG.getNode(ISD::SELECT_CC, TheSelect->getDebugLoc(),
|
||||||
TheSelect->getOperand(0),
|
LLD->getBasePtr().getValueType(),
|
||||||
TheSelect->getOperand(1),
|
TheSelect->getOperand(0),
|
||||||
LLD->getBasePtr(), RLD->getBasePtr(),
|
TheSelect->getOperand(1),
|
||||||
TheSelect->getOperand(4));
|
LLD->getBasePtr(), RLD->getBasePtr(),
|
||||||
|
TheSelect->getOperand(4));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user