[PATCH] D86609: [AMDGPU][GlobalISel] Eliminate barrier if workgroup size is not greater than wavefront size
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 05:52:31 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG831457c6d59e: [AMDGPU][GlobalISel] Eliminate barrier if workgroup size is not greater than… (authored by foad).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86609/new/
https://reviews.llvm.org/D86609
Files:
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
llvm/test/CodeGen/AMDGPU/barrier-elimination.ll
Index: llvm/test/CodeGen/AMDGPU/barrier-elimination.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/barrier-elimination.ll
+++ llvm/test/CodeGen/AMDGPU/barrier-elimination.ll
@@ -1,4 +1,5 @@
; RUN: llc -march=amdgcn < %s | FileCheck %s
+; RUN: llc -march=amdgcn < %s -global-isel | FileCheck %s
; CHECK-LABEL: {{^}}unknown_wgs:
; CHECK: s_barrier
Index: llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
+++ llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
@@ -118,6 +118,7 @@
bool selectDSOrderedIntrinsic(MachineInstr &MI, Intrinsic::ID IID) const;
bool selectDSGWSIntrinsic(MachineInstr &MI, Intrinsic::ID IID) const;
bool selectDSAppendConsume(MachineInstr &MI, bool IsAppend) const;
+ bool selectSBarrier(MachineInstr &MI) const;
bool selectImageIntrinsic(MachineInstr &MI,
const AMDGPU::ImageDimIntrinsicInfo *Intr) const;
Index: llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -1422,6 +1422,20 @@
return constrainSelectedInstRegOperands(*MIB, TII, TRI, RBI);
}
+bool AMDGPUInstructionSelector::selectSBarrier(MachineInstr &MI) const {
+ if (TM.getOptLevel() > CodeGenOpt::None) {
+ unsigned WGSize = STI.getFlatWorkGroupSizes(MF->getFunction()).second;
+ if (WGSize <= STI.getWavefrontSize()) {
+ MachineBasicBlock *MBB = MI.getParent();
+ const DebugLoc &DL = MI.getDebugLoc();
+ BuildMI(*MBB, &MI, DL, TII.get(AMDGPU::WAVE_BARRIER));
+ MI.eraseFromParent();
+ return true;
+ }
+ }
+ return selectImpl(MI, *CoverageInfo);
+}
+
static bool parseTexFail(uint64_t TexFailCtrl, bool &TFE, bool &LWE,
bool &IsTexFail) {
if (TexFailCtrl)
@@ -1726,6 +1740,8 @@
return selectDSAppendConsume(I, true);
case Intrinsic::amdgcn_ds_consume:
return selectDSAppendConsume(I, false);
+ case Intrinsic::amdgcn_s_barrier:
+ return selectSBarrier(I);
default: {
return selectImpl(I, *CoverageInfo);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86609.287944.patch
Type: text/x-patch
Size: 2308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200826/46558d84/attachment.bin>
More information about the llvm-commits
mailing list