mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
AMDGPU: Cleanup SMRD buffer selection
The usage of the Imm out argument from SelectSMRDOffset is pretty confusing. Stop trying to reject CI immediates in the case where the offset field can be used. It's not an illegal way to encode the immediate, so just prefer the better encoding pattern with AddedComplexity. We probably don't even really need the different opcodes for the different offset types anymore, but that will be more work to cleanup. The SMRD non-buffer load patterns could also use a cleanup to be done separately.
This commit is contained in:
parent
edc134394e
commit
d5d8b833fb
@ -1874,19 +1874,30 @@ bool AMDGPUDAGToDAGISel::SelectSMRDSgpr(SDValue Addr, SDValue &SBase,
|
||||
|
||||
bool AMDGPUDAGToDAGISel::SelectSMRDBufferImm(SDValue Addr,
|
||||
SDValue &Offset) const {
|
||||
bool Imm = false;
|
||||
return SelectSMRDOffset(Addr, Offset, Imm) && Imm;
|
||||
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Addr)) {
|
||||
if (auto Imm = AMDGPU::getSMRDEncodedOffset(*Subtarget,
|
||||
C->getZExtValue())) {
|
||||
Offset = CurDAG->getTargetConstant(*Imm, SDLoc(Addr), MVT::i32);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AMDGPUDAGToDAGISel::SelectSMRDBufferImm32(SDValue Addr,
|
||||
SDValue &Offset) const {
|
||||
assert(Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS);
|
||||
|
||||
bool Imm = false;
|
||||
if (!SelectSMRDOffset(Addr, Offset, Imm))
|
||||
return false;
|
||||
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Addr)) {
|
||||
if (auto Imm = AMDGPU::getSMRDEncodedLiteralOffset32(*Subtarget,
|
||||
C->getZExtValue())) {
|
||||
Offset = CurDAG->getTargetConstant(*Imm, SDLoc(Addr), MVT::i32);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return !Imm && isa<ConstantSDNode>(Offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AMDGPUDAGToDAGISel::SelectMOVRELOffset(SDValue Index,
|
||||
|
@ -770,14 +770,16 @@ multiclass SMLoad_Pattern <string Instr, ValueType vt> {
|
||||
def : GCNPat <
|
||||
(SIsbuffer_load v4i32:$sbase, (SMRDBufferImm i32:$offset), timm:$cachepolicy),
|
||||
(vt (!cast<SM_Pseudo>(Instr#"_IMM") $sbase, $offset, (extract_glc $cachepolicy),
|
||||
(extract_dlc $cachepolicy)))
|
||||
>;
|
||||
(extract_dlc $cachepolicy)))> {
|
||||
let AddedComplexity = 2;
|
||||
}
|
||||
|
||||
// 2. 32-bit IMM offset on CI
|
||||
def : GCNPat <
|
||||
(vt (SIsbuffer_load v4i32:$sbase, (SMRDBufferImm32 i32:$offset), timm:$cachepolicy)),
|
||||
(!cast<InstSI>(Instr#"_IMM_ci") $sbase, $offset, (extract_glc $cachepolicy), (extract_dlc $cachepolicy))> {
|
||||
let OtherPredicates = [isGFX7Only];
|
||||
let AddedComplexity = 1;
|
||||
}
|
||||
|
||||
// 3. Offset loaded in an 32bit SGPR
|
||||
|
Loading…
x
Reference in New Issue
Block a user