Open Quuxplusone opened 8 years ago
Attached reduced-t002.ll
(1020 bytes, application/octet-stream): testcase .ll
Attached view-combine2.dot
(4928 bytes, text/plain): view-dag-combine2-dags dot file
Attached view-isel.dot
(3387 bytes, text/plain): view-isel-dags dot file
disabling this transformation "fixes" it (and, incidentally, generates what
looks like better code), however, not sure of the wider implications…
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -1763,7 +1763,7 @@ bool PPCTargetLowering::SelectAddressRegImm(SDValue N,
SDValue &Disp,
Base = N.getOperand(0);
}
return true; // [r+i]
- } else if (N.getOperand(1).getOpcode() == PPCISD::Lo) {
+ } else if (N.getOperand(1).getOpcode() == PPCISD::Lo && 0) {
// Match LOAD (ADD (X, Lo(G))).
assert(!cast<ConstantSDNode>(N.getOperand(1).getOperand(1))->getZExtValue()
&& "Cannot handle constant offsets yet!");
The problem here is that this interacts with other parts of the lowering;
for linux this path only seems to be executed when non-pic. However, if I fix
it to not generate bad insns (e.g. with the concoction below) - then we get a
regression in MergeConsecutiveStores.ll. Hm.
For Darwin, the "common" case is not problematic, since the OS indirects
accesses to common.
--- anyway, probably out of cycles to look at this for now.
Anyone know how this is supposed to interact with following opts?
some experimentation:
lib/Target/PowerPC/PPCISelLowering.cpp;
} else if (N.getOperand(1).getOpcode() == PPCISD::Lo) {
// Match LOAD (ADD (X, Lo(G))), under what conditions ???
assert(!cast<ConstantSDNode>(N.getOperand(1).getOperand(1))->getZExtValue()
&& "Cannot handle constant offsets yet!");
//N.getNode()->dumpr(&DAG);
Disp = N.getOperand(1).getOperand(0); // The global address.
Base = N.getOperand(0);
if (Disp.getOpcode() == ISD::TargetGlobalAddress) {
GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Disp);
unsigned char TF = GA->getTargetFlags();
bool IsComm = GA->getGlobal()->hasCommonLinkage ();
bool IsSDL = GA->getGlobal()->isStrongDefinitionForLinker ();
//GA->getGlobal()->dump();
bool IsPic = (TF & PPCII::MO_PIC_FLAG);
if ((IsPic && (TF & PPCII::MO_NLP_FLAG)) || (!IsPic && !IsSDL && !IsComm))
return true; // [&g+r] is OK
// else don't transform.
oops the whole chunk of experimental code is
} else if (N.getOperand(1).getOpcode() == PPCISD::Lo) {
// Match LOAD (ADD (X, Lo(G))), when no fixup will be required.
assert(!cast<ConstantSDNode>(N.getOperand(1).getOperand(1))->getZExtValue()
&& "Cannot handle constant offsets yet!");
//N.getNode()->dumpr(&DAG);
Disp = N.getOperand(1).getOperand(0); // The global address.
Base = N.getOperand(0);
if (Disp.getOpcode() == ISD::TargetGlobalAddress) {
GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Disp);
unsigned char TF = GA->getTargetFlags();
bool IsComm = GA->getGlobal()->hasCommonLinkage ();
bool IsSDL = GA->getGlobal()->isStrongDefinitionForLinker ();
//GA->getGlobal()->dump();
bool IsPic = (TF & PPCII::MO_PIC_FLAG);
if ((IsPic && (TF & PPCII::MO_NLP_FLAG)) || (!IsPic && !IsSDL && !IsComm))
return true; // [&g+r] is OK
// else don't transform.
} else {
assert(Disp.getOpcode() == ISD::TargetGlobalTLSAddress ||
Disp.getOpcode() == ISD::TargetConstantPool ||
Disp.getOpcode() == ISD::TargetJumpTable);
return true; // [&g+r]
}
}
reduced-t002.ll
(1020 bytes, application/octet-stream)view-combine2.dot
(4928 bytes, text/plain)view-isel.dot
(3387 bytes, text/plain)