mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
Move isConsecutiveLoad to SelectionDAG. It's not target dependent and it's primary used by selectdag passes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90922 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d632988eea
commit
64fa4a9584
@ -890,6 +890,12 @@ public:
|
||||
/// vector op and fill the end of the resulting vector with UNDEFS.
|
||||
SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0);
|
||||
|
||||
/// isConsecutiveLoad - Return true if LD is loading 'Bytes' bytes from a
|
||||
/// location that is 'Dist' units away from the location that the 'Base' load
|
||||
/// is loading from.
|
||||
bool isConsecutiveLoad(LoadSDNode *LD, LoadSDNode *Base,
|
||||
unsigned Bytes, int Dist) const;
|
||||
|
||||
/// InferPtrAlignment - Infer alignment of a load / store address. Return 0 if
|
||||
/// it cannot be inferred.
|
||||
unsigned InferPtrAlignment(SDValue Ptr) const;
|
||||
|
@ -857,12 +857,6 @@ public:
|
||||
virtual bool
|
||||
isGAPlusOffset(SDNode *N, GlobalValue* &GA, int64_t &Offset) const;
|
||||
|
||||
/// isConsecutiveLoad - Return true if LD is loading 'Bytes' bytes from a
|
||||
/// location that is 'Dist' units away from the location that the 'Base' load
|
||||
/// is loading from.
|
||||
bool isConsecutiveLoad(LoadSDNode *LD, LoadSDNode *Base, unsigned Bytes,
|
||||
int Dist, const MachineFrameInfo *MFI) const;
|
||||
|
||||
/// PerformDAGCombine - This method will be invoked for all target nodes and
|
||||
/// for any target-independent nodes that the target has registered with
|
||||
/// invoke it for.
|
||||
|
@ -3688,7 +3688,6 @@ SDValue DAGCombiner::CombineConsecutiveLoads(SDNode *N, EVT VT) {
|
||||
if (!LD1 || !LD2 || !ISD::isNON_EXTLoad(LD1) || !LD1->hasOneUse())
|
||||
return SDValue();
|
||||
EVT LD1VT = LD1->getValueType(0);
|
||||
const MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo();
|
||||
|
||||
if (ISD::isNON_EXTLoad(LD2) &&
|
||||
LD2->hasOneUse() &&
|
||||
@ -3696,7 +3695,7 @@ SDValue DAGCombiner::CombineConsecutiveLoads(SDNode *N, EVT VT) {
|
||||
// If one is volatile it might be ok, but play conservative and bail out.
|
||||
!LD1->isVolatile() &&
|
||||
!LD2->isVolatile() &&
|
||||
TLI.isConsecutiveLoad(LD2, LD1, LD1VT.getSizeInBits()/8, 1, MFI)) {
|
||||
DAG.isConsecutiveLoad(LD2, LD1, LD1VT.getSizeInBits()/8, 1)) {
|
||||
unsigned Align = LD1->getAlignment();
|
||||
unsigned NewAlign = TLI.getTargetData()->
|
||||
getABITypeAlignment(VT.getTypeForEVT(*DAG.getContext()));
|
||||
|
@ -5868,6 +5868,49 @@ SDValue SelectionDAG::UnrollVectorOp(SDNode *N, unsigned ResNE) {
|
||||
&Scalars[0], Scalars.size());
|
||||
}
|
||||
|
||||
|
||||
/// isConsecutiveLoad - Return true if LD is loading 'Bytes' bytes from a
|
||||
/// location that is 'Dist' units away from the location that the 'Base' load
|
||||
/// is loading from.
|
||||
bool SelectionDAG::isConsecutiveLoad(LoadSDNode *LD, LoadSDNode *Base,
|
||||
unsigned Bytes, int Dist) const {
|
||||
if (LD->getChain() != Base->getChain())
|
||||
return false;
|
||||
EVT VT = LD->getValueType(0);
|
||||
if (VT.getSizeInBits() / 8 != Bytes)
|
||||
return false;
|
||||
|
||||
SDValue Loc = LD->getOperand(1);
|
||||
SDValue BaseLoc = Base->getOperand(1);
|
||||
if (Loc.getOpcode() == ISD::FrameIndex) {
|
||||
if (BaseLoc.getOpcode() != ISD::FrameIndex)
|
||||
return false;
|
||||
const MachineFrameInfo *MFI = getMachineFunction().getFrameInfo();
|
||||
int FI = cast<FrameIndexSDNode>(Loc)->getIndex();
|
||||
int BFI = cast<FrameIndexSDNode>(BaseLoc)->getIndex();
|
||||
int FS = MFI->getObjectSize(FI);
|
||||
int BFS = MFI->getObjectSize(BFI);
|
||||
if (FS != BFS || FS != (int)Bytes) return false;
|
||||
return MFI->getObjectOffset(FI) == (MFI->getObjectOffset(BFI) + Dist*Bytes);
|
||||
}
|
||||
if (Loc.getOpcode() == ISD::ADD && Loc.getOperand(0) == BaseLoc) {
|
||||
ConstantSDNode *V = dyn_cast<ConstantSDNode>(Loc.getOperand(1));
|
||||
if (V && (V->getSExtValue() == Dist*Bytes))
|
||||
return true;
|
||||
}
|
||||
|
||||
GlobalValue *GV1 = NULL;
|
||||
GlobalValue *GV2 = NULL;
|
||||
int64_t Offset1 = 0;
|
||||
int64_t Offset2 = 0;
|
||||
bool isGA1 = TLI.isGAPlusOffset(Loc.getNode(), GV1, Offset1);
|
||||
bool isGA2 = TLI.isGAPlusOffset(BaseLoc.getNode(), GV2, Offset2);
|
||||
if (isGA1 && isGA2 && GV1 == GV2)
|
||||
return Offset1 == (Offset2 + Dist*Bytes);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// InferPtrAlignment - Infer alignment of a load / store address. Return 0 if
|
||||
/// it cannot be inferred.
|
||||
unsigned SelectionDAG::InferPtrAlignment(SDValue Ptr) const {
|
||||
|
@ -2184,48 +2184,6 @@ bool TargetLowering::isGAPlusOffset(SDNode *N, GlobalValue* &GA,
|
||||
}
|
||||
|
||||
|
||||
/// isConsecutiveLoad - Return true if LD is loading 'Bytes' bytes from a
|
||||
/// location that is 'Dist' units away from the location that the 'Base' load
|
||||
/// is loading from.
|
||||
bool TargetLowering::isConsecutiveLoad(LoadSDNode *LD, LoadSDNode *Base,
|
||||
unsigned Bytes, int Dist,
|
||||
const MachineFrameInfo *MFI) const {
|
||||
if (LD->getChain() != Base->getChain())
|
||||
return false;
|
||||
EVT VT = LD->getValueType(0);
|
||||
if (VT.getSizeInBits() / 8 != Bytes)
|
||||
return false;
|
||||
|
||||
SDValue Loc = LD->getOperand(1);
|
||||
SDValue BaseLoc = Base->getOperand(1);
|
||||
if (Loc.getOpcode() == ISD::FrameIndex) {
|
||||
if (BaseLoc.getOpcode() != ISD::FrameIndex)
|
||||
return false;
|
||||
int FI = cast<FrameIndexSDNode>(Loc)->getIndex();
|
||||
int BFI = cast<FrameIndexSDNode>(BaseLoc)->getIndex();
|
||||
int FS = MFI->getObjectSize(FI);
|
||||
int BFS = MFI->getObjectSize(BFI);
|
||||
if (FS != BFS || FS != (int)Bytes) return false;
|
||||
return MFI->getObjectOffset(FI) == (MFI->getObjectOffset(BFI) + Dist*Bytes);
|
||||
}
|
||||
if (Loc.getOpcode() == ISD::ADD && Loc.getOperand(0) == BaseLoc) {
|
||||
ConstantSDNode *V = dyn_cast<ConstantSDNode>(Loc.getOperand(1));
|
||||
if (V && (V->getSExtValue() == Dist*Bytes))
|
||||
return true;
|
||||
}
|
||||
|
||||
GlobalValue *GV1 = NULL;
|
||||
GlobalValue *GV2 = NULL;
|
||||
int64_t Offset1 = 0;
|
||||
int64_t Offset2 = 0;
|
||||
bool isGA1 = isGAPlusOffset(Loc.getNode(), GV1, Offset1);
|
||||
bool isGA2 = isGAPlusOffset(BaseLoc.getNode(), GV2, Offset2);
|
||||
if (isGA1 && isGA2 && GV1 == GV2)
|
||||
return Offset1 == (Offset2 + Dist*Bytes);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SDValue TargetLowering::
|
||||
PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const {
|
||||
// Default implementation: no optimization.
|
||||
|
@ -8366,7 +8366,7 @@ static bool EltsFromConsecutiveLoads(ShuffleVectorSDNode *N, unsigned NumElems,
|
||||
continue;
|
||||
|
||||
LoadSDNode *LD = cast<LoadSDNode>(Elt);
|
||||
if (!TLI.isConsecutiveLoad(LD, LDBase, EltVT.getSizeInBits()/8, i, MFI))
|
||||
if (!DAG.isConsecutiveLoad(LD, LDBase, EltVT.getSizeInBits()/8, i))
|
||||
return false;
|
||||
LastLoadedElt = i;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user