[llvm] r303658 - AMDGPU: Fold CI-specific complex SMRD patterns into existing complex patterns
Marek Olsak via llvm-commits
llvm-commits at lists.llvm.org
Tue May 23 10:14:35 PDT 2017
Author: mareko
Date: Tue May 23 12:14:34 2017
New Revision: 303658
URL: http://llvm.org/viewvc/llvm-project?rev=303658&view=rev
Log:
AMDGPU: Fold CI-specific complex SMRD patterns into existing complex patterns
This is just a cleanup. Also, it adds checking that ByteCount is aligned to 4.
Reviewers: arsenm, nhaehnle, tstellarAMD
Subscribers: kzhuravl, wdng, yaxunl, tony-tye
Differential Revision: https://reviews.llvm.org/D28994
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h
llvm/trunk/lib/Target/AMDGPU/SMInstructions.td
llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp?rev=303658&r1=303657&r2=303658&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp Tue May 23 12:14:34 2017
@@ -145,10 +145,8 @@ private:
bool SelectSMRD(SDValue Addr, SDValue &SBase, SDValue &Offset,
bool &Imm) const;
bool SelectSMRDImm(SDValue Addr, SDValue &SBase, SDValue &Offset) const;
- bool SelectSMRDImm32(SDValue Addr, SDValue &SBase, SDValue &Offset) const;
bool SelectSMRDSgpr(SDValue Addr, SDValue &SBase, SDValue &Offset) const;
bool SelectSMRDBufferImm(SDValue Addr, SDValue &Offset) const;
- bool SelectSMRDBufferImm32(SDValue Addr, SDValue &Offset) const;
bool SelectSMRDBufferSgpr(SDValue Addr, SDValue &Offset) const;
bool SelectMOVRELOffset(SDValue Index, SDValue &Base, SDValue &Offset) const;
@@ -1330,7 +1328,6 @@ bool AMDGPUDAGToDAGISel::SelectSMRDOffse
return false;
SDLoc SL(ByteOffsetNode);
- AMDGPUSubtarget::Generation Gen = Subtarget->getGeneration();
int64_t ByteOffset = C->getSExtValue();
int64_t EncodedOffset = AMDGPU::getSMRDEncodedOffset(*Subtarget, ByteOffset);
@@ -1343,8 +1340,8 @@ bool AMDGPUDAGToDAGISel::SelectSMRDOffse
if (!isUInt<32>(EncodedOffset) || !isUInt<32>(ByteOffset))
return false;
- if (Gen == AMDGPUSubtarget::SEA_ISLANDS && isUInt<32>(EncodedOffset)) {
- // 32-bit Immediates are supported on Sea Islands.
+ if (Subtarget->has32BitLiteralSMRDOffset() &&
+ ByteOffset % 4 == 0 && isUInt<32>(EncodedOffset)) {
Offset = CurDAG->getTargetConstant(EncodedOffset, SL, MVT::i32);
} else {
SDValue C32Bit = CurDAG->getTargetConstant(ByteOffset, SL, MVT::i32);
@@ -1376,20 +1373,15 @@ bool AMDGPUDAGToDAGISel::SelectSMRD(SDVa
bool AMDGPUDAGToDAGISel::SelectSMRDImm(SDValue Addr, SDValue &SBase,
SDValue &Offset) const {
bool Imm;
- return SelectSMRD(Addr, SBase, Offset, Imm) && Imm;
-}
-
-bool AMDGPUDAGToDAGISel::SelectSMRDImm32(SDValue Addr, SDValue &SBase,
- SDValue &Offset) const {
-
- if (Subtarget->getGeneration() != AMDGPUSubtarget::SEA_ISLANDS)
- return false;
- bool Imm;
if (!SelectSMRD(Addr, SBase, Offset, Imm))
return false;
- return !Imm && isa<ConstantSDNode>(Offset);
+ if (Subtarget->has32BitLiteralSMRDOffset() &&
+ isa<ConstantSDNode>(Offset))
+ return true;
+
+ return Imm;
}
bool AMDGPUDAGToDAGISel::SelectSMRDSgpr(SDValue Addr, SDValue &SBase,
@@ -1402,19 +1394,15 @@ bool AMDGPUDAGToDAGISel::SelectSMRDSgpr(
bool AMDGPUDAGToDAGISel::SelectSMRDBufferImm(SDValue Addr,
SDValue &Offset) const {
bool Imm;
- return SelectSMRDOffset(Addr, Offset, Imm) && Imm;
-}
-
-bool AMDGPUDAGToDAGISel::SelectSMRDBufferImm32(SDValue Addr,
- SDValue &Offset) const {
- if (Subtarget->getGeneration() != AMDGPUSubtarget::SEA_ISLANDS)
- return false;
- bool Imm;
if (!SelectSMRDOffset(Addr, Offset, Imm))
return false;
- return !Imm && isa<ConstantSDNode>(Offset);
+ if (Subtarget->has32BitLiteralSMRDOffset() &&
+ isa<ConstantSDNode>(Offset))
+ return true;
+
+ return Imm;
}
bool AMDGPUDAGToDAGISel::SelectSMRDBufferSgpr(SDValue Addr,
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h?rev=303658&r1=303657&r2=303658&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h Tue May 23 12:14:34 2017
@@ -399,6 +399,10 @@ public:
return FlatScratchInsts;
}
+ bool has32BitLiteralSMRDOffset() const {
+ return getGeneration() == SEA_ISLANDS;
+ }
+
bool isMesaKernel(const MachineFunction &MF) const {
return isMesa3DOS() && !AMDGPU::isShader(MF.getFunction()->getCallingConv());
}
Modified: llvm/trunk/lib/Target/AMDGPU/SMInstructions.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SMInstructions.td?rev=303658&r1=303657&r2=303658&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SMInstructions.td (original)
+++ llvm/trunk/lib/Target/AMDGPU/SMInstructions.td Tue May 23 12:14:34 2017
@@ -234,10 +234,8 @@ def smrd_load : PatFrag <(ops node:$ptr)
}]>;
def SMRDImm : ComplexPattern<i64, 2, "SelectSMRDImm">;
-def SMRDImm32 : ComplexPattern<i64, 2, "SelectSMRDImm32">;
def SMRDSgpr : ComplexPattern<i64, 2, "SelectSMRDSgpr">;
def SMRDBufferImm : ComplexPattern<i32, 1, "SelectSMRDBufferImm">;
-def SMRDBufferImm32 : ComplexPattern<i32, 1, "SelectSMRDBufferImm32">;
def SMRDBufferSgpr : ComplexPattern<i32, 1, "SelectSMRDBufferSgpr">;
let Predicates = [isGCN] in {
@@ -276,7 +274,7 @@ defm : SMRD_Pattern <"S_LOAD_DWORDX8",
defm : SMRD_Pattern <"S_LOAD_DWORDX16", v16i32>;
// 1. Offset as an immediate
-def SM_LOAD_PATTERN : Pat < // name this pattern to reuse AddedComplexity on CI
+def : Pat <
(SIload_constant v4i32:$sbase, (SMRDBufferImm i32:$offset)),
(S_BUFFER_LOAD_DWORD_IMM $sbase, $offset, 0)
>;
@@ -504,26 +502,3 @@ class SMRD_Real_ci <bits<5> op, SM_Pseud
}
def S_DCACHE_INV_VOL_ci : SMRD_Real_ci <0x1d, S_DCACHE_INV_VOL>;
-
-let AddedComplexity = SM_LOAD_PATTERN.AddedComplexity in {
-
-class SMRD_Pattern_ci <string Instr, ValueType vt> : Pat <
- (smrd_load (SMRDImm32 i64:$sbase, i32:$offset)),
- (vt (!cast<SM_Pseudo>(Instr#"_IMM_ci") $sbase, $offset, 0))> {
- let Predicates = [isCIOnly];
-}
-
-def : SMRD_Pattern_ci <"S_LOAD_DWORD", i32>;
-def : SMRD_Pattern_ci <"S_LOAD_DWORDX2", v2i32>;
-def : SMRD_Pattern_ci <"S_LOAD_DWORDX4", v4i32>;
-def : SMRD_Pattern_ci <"S_LOAD_DWORDX8", v8i32>;
-def : SMRD_Pattern_ci <"S_LOAD_DWORDX16", v16i32>;
-
-def : Pat <
- (SIload_constant v4i32:$sbase, (SMRDBufferImm32 i32:$offset)),
- (S_BUFFER_LOAD_DWORD_IMM_ci $sbase, $offset, 0)> {
- let Predicates = [isCI]; // should this be isCIOnly?
-}
-
-} // End let AddedComplexity = SM_LOAD_PATTERN.AddedComplexity
-
Modified: llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp?rev=303658&r1=303657&r2=303658&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp Tue May 23 12:14:34 2017
@@ -763,7 +763,7 @@ int64_t getSMRDEncodedOffset(const MCSub
bool isLegalSMRDImmOffset(const MCSubtargetInfo &ST, int64_t ByteOffset) {
int64_t EncodedOffset = getSMRDEncodedOffset(ST, ByteOffset);
- return isSI(ST) || isCI(ST) ? isUInt<8>(EncodedOffset) :
+ return isSI(ST) || isCI(ST) ? ByteOffset % 4 == 0 && isUInt<8>(EncodedOffset) :
isUInt<20>(EncodedOffset);
}
} // end namespace AMDGPU
More information about the llvm-commits
mailing list