Skip to content

Commit 73bb836

Browse files
committed
[AMDGPU][AMDGPUDemoteSCCBranchToExecz] create new pass (boilerplate only)
Change-Id: Ic9e84df17a9c8c24a28dea4c4e811256cf44896f
1 parent 8c32fb0 commit 73bb836

File tree

6 files changed

+72
-1
lines changed

6 files changed

+72
-1
lines changed

llvm/lib/Target/AMDGPU/AMDGPU.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,17 @@ extern char &AMDGPUCodeGenPrepareID;
373373
void initializeAMDGPURemoveIncompatibleFunctionsPass(PassRegistry &);
374374
extern char &AMDGPURemoveIncompatibleFunctionsID;
375375

376+
void initializeAMDGPUDemoteSCCBranchToExeczLegacyPass(PassRegistry &);
377+
extern char &AMDGPUDemoteSCCBranchToExeczLegacyID;
378+
379+
class AMDGPUDemoteSCCBranchToExeczPass
380+
: public PassInfoMixin<AMDGPUDemoteSCCBranchToExeczPass> {
381+
public:
382+
AMDGPUDemoteSCCBranchToExeczPass() = default;
383+
PreservedAnalyses run(MachineFunction &MF,
384+
MachineFunctionAnalysisManager &MFAM);
385+
};
386+
376387
void initializeAMDGPULateCodeGenPrepareLegacyPass(PassRegistry &);
377388
extern char &AMDGPULateCodeGenPrepareLegacyID;
378389

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <llvm/CodeGen/MachineFunctionPass.h>
2+
3+
#include "AMDGPU.h"
4+
5+
using namespace llvm;
6+
7+
namespace {
8+
#define DEBUG_TYPE "amdgpu-demote-scc-to-execz"
9+
const char PassName[] = "AMDGPU if conversion";
10+
11+
class AMDGPUDemoteSCCBranchToExecz {
12+
public:
13+
AMDGPUDemoteSCCBranchToExecz() = default;
14+
15+
bool run() { return false; }
16+
};
17+
18+
class AMDGPUDemoteSCCBranchToExeczLegacy : public MachineFunctionPass {
19+
public:
20+
static char ID;
21+
22+
AMDGPUDemoteSCCBranchToExeczLegacy() : MachineFunctionPass(ID) {}
23+
24+
bool runOnMachineFunction(MachineFunction &MF) override {
25+
AMDGPUDemoteSCCBranchToExecz IfCvt{};
26+
return IfCvt.run();
27+
}
28+
29+
void getAnalysisUsage(AnalysisUsage &AU) const override {
30+
MachineFunctionPass::getAnalysisUsage(AU);
31+
}
32+
33+
StringRef getPassName() const override { return PassName; }
34+
};
35+
36+
char AMDGPUDemoteSCCBranchToExeczLegacy::ID = 0;
37+
38+
} // namespace
39+
40+
PreservedAnalyses llvm::AMDGPUDemoteSCCBranchToExeczPass::run(
41+
MachineFunction &MF, MachineFunctionAnalysisManager &MFAM) {
42+
AMDGPUDemoteSCCBranchToExecz IfCvt{};
43+
if (!IfCvt.run())
44+
return PreservedAnalyses::all();
45+
return PreservedAnalyses::none();
46+
}
47+
48+
char &llvm::AMDGPUDemoteSCCBranchToExeczLegacyID =
49+
AMDGPUDemoteSCCBranchToExeczLegacy::ID;
50+
INITIALIZE_PASS_BEGIN(AMDGPUDemoteSCCBranchToExeczLegacy, DEBUG_TYPE, PassName,
51+
false, false)
52+
INITIALIZE_PASS_END(AMDGPUDemoteSCCBranchToExeczLegacy, DEBUG_TYPE, PassName,
53+
false, false)

llvm/lib/Target/AMDGPU/AMDGPUPassRegistry.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ FUNCTION_PASS_WITH_PARAMS(
9595
#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS)
9696
#endif
9797
MACHINE_FUNCTION_PASS("amdgpu-isel", AMDGPUISelDAGToDAGPass(*this))
98+
MACHINE_FUNCTION_PASS("amdgpu-demote-scc-to-execz", AMDGPUDemoteSCCBranchToExeczPass())
9899
MACHINE_FUNCTION_PASS("si-fix-sgpr-copies", SIFixSGPRCopiesPass())
99100
MACHINE_FUNCTION_PASS("si-i1-copies", SILowerI1CopiesPass())
100101
MACHINE_FUNCTION_PASS("si-fold-operands", SIFoldOperandsPass());

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() {
496496
initializeAMDGPURewriteUndefForPHILegacyPass(*PR);
497497
initializeAMDGPUUnifyMetadataPass(*PR);
498498
initializeSIAnnotateControlFlowLegacyPass(*PR);
499+
initializeAMDGPUDemoteSCCBranchToExeczLegacyPass(*PR);
499500
initializeAMDGPUInsertDelayAluPass(*PR);
500501
initializeSIInsertHardClausesPass(*PR);
501502
initializeSIInsertWaitcntsPass(*PR);
@@ -1334,7 +1335,7 @@ void GCNPassConfig::addMachineSSAOptimization() {
13341335
bool GCNPassConfig::addILPOpts() {
13351336
if (EnableEarlyIfConversion)
13361337
addPass(&EarlyIfConverterID);
1337-
1338+
addPass(&AMDGPUDemoteSCCBranchToExeczLegacyID);
13381339
TargetPassConfig::addILPOpts();
13391340
return false;
13401341
}

llvm/lib/Target/AMDGPU/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ add_llvm_target(AMDGPUCodeGen
5959
AMDGPUGlobalISelDivergenceLowering.cpp
6060
AMDGPUGlobalISelUtils.cpp
6161
AMDGPUHSAMetadataStreamer.cpp
62+
AMDGPUDemoteSCCBranchToExecz.cpp
6263
AMDGPUInsertDelayAlu.cpp
6364
AMDGPUInstCombineIntrinsic.cpp
6465
AMDGPUInstrInfo.cpp

llvm/test/CodeGen/AMDGPU/llc-pipeline.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@
315315
; GCN-O1-NEXT: Merge disjoint stack slots
316316
; GCN-O1-NEXT: Local Stack Slot Allocation
317317
; GCN-O1-NEXT: Remove dead machine instructions
318+
; GCN-O1-NEXT: AMDGPU s_cbranch_scc to s_cbranch_execz conversion
318319
; GCN-O1-NEXT: MachineDominator Tree Construction
319320
; GCN-O1-NEXT: Machine Natural Loop Construction
320321
; GCN-O1-NEXT: Machine Block Frequency Analysis
@@ -617,6 +618,7 @@
617618
; GCN-O1-OPTS-NEXT: Merge disjoint stack slots
618619
; GCN-O1-OPTS-NEXT: Local Stack Slot Allocation
619620
; GCN-O1-OPTS-NEXT: Remove dead machine instructions
621+
; GCN-O1-OPTS-NEXT: AMDGPU s_cbranch_scc to s_cbranch_execz conversion
620622
; GCN-O1-OPTS-NEXT: MachineDominator Tree Construction
621623
; GCN-O1-OPTS-NEXT: Machine Natural Loop Construction
622624
; GCN-O1-OPTS-NEXT: Machine Block Frequency Analysis
@@ -932,6 +934,7 @@
932934
; GCN-O2-NEXT: Merge disjoint stack slots
933935
; GCN-O2-NEXT: Local Stack Slot Allocation
934936
; GCN-O2-NEXT: Remove dead machine instructions
937+
; GCN-O2-NEXT: AMDGPU s_cbranch_scc to s_cbranch_execz conversion
935938
; GCN-O2-NEXT: MachineDominator Tree Construction
936939
; GCN-O2-NEXT: Machine Natural Loop Construction
937940
; GCN-O2-NEXT: Machine Block Frequency Analysis
@@ -1260,6 +1263,7 @@
12601263
; GCN-O3-NEXT: Merge disjoint stack slots
12611264
; GCN-O3-NEXT: Local Stack Slot Allocation
12621265
; GCN-O3-NEXT: Remove dead machine instructions
1266+
; GCN-O3-NEXT: AMDGPU s_cbranch_scc to s_cbranch_execz conversion
12631267
; GCN-O3-NEXT: MachineDominator Tree Construction
12641268
; GCN-O3-NEXT: Machine Natural Loop Construction
12651269
; GCN-O3-NEXT: Machine Block Frequency Analysis

0 commit comments

Comments
 (0)