[llvm] [AMDGPU][NewPM] Fill out AMDGPU addMachineSSAOptimizations (PR #111658)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 9 22:17:29 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Akshat Oke (Akshat-Oke)
<details>
<summary>Changes</summary>
Implement the addMachineSSAOptimizations passes for AMDGPU. I'm porting the other generic passes in this category.
---
Full diff: https://github.com/llvm/llvm-project/pull/111658.diff
2 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+21)
- (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h (+1)
``````````diff
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 2c84cdac76d027..23ee0c3e896eb3 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -47,6 +47,7 @@
#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/Analysis/CallGraphSCCPass.h"
#include "llvm/Analysis/UniformityAnalysis.h"
+#include "llvm/CodeGen/DeadMachineInstructionElim.h"
#include "llvm/CodeGen/GlobalISel/CSEInfo.h"
#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
#include "llvm/CodeGen/GlobalISel/InstructionSelect.h"
@@ -54,6 +55,7 @@
#include "llvm/CodeGen/GlobalISel/Localizer.h"
#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
#include "llvm/CodeGen/MIRParser/MIParser.h"
+#include "llvm/CodeGen/MachineCSE.h"
#include "llvm/CodeGen/MachineLICM.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/RegAllocRegistry.h"
@@ -1993,6 +1995,25 @@ Error AMDGPUCodeGenPassBuilder::addInstSelector(AddMachinePass &addPass) const {
return Error::success();
}
+void AMDGPUCodeGenPassBuilder::addMachineSSAOptimization(
+ AddMachinePass &addPass) const {
+ Base::addMachineSSAOptimization(addPass);
+
+ addPass(SIFoldOperandsPass());
+ if (EnableDPPCombine) {
+ addPass(GCNDPPCombinePass());
+ }
+ addPass(SILoadStoreOptimizerPass());
+ if (isPassEnabled(EnableSDWAPeephole)) {
+ addPass(SIPeepholeSDWAPass());
+ addPass(EarlyMachineLICMPass());
+ addPass(MachineCSEPass());
+ addPass(SIFoldOperandsPass());
+ }
+ addPass(DeadMachineInstructionElimPass());
+ addPass(SIShrinkInstructionsPass());
+}
+
bool AMDGPUCodeGenPassBuilder::isPassEnabled(const cl::opt<bool> &Opt,
CodeGenOptLevel Level) const {
if (Opt.getNumOccurrences())
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
index 5b7257ddb36f1e..af8476bc21ec61 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
@@ -174,6 +174,7 @@ class AMDGPUCodeGenPassBuilder
void addPreISel(AddIRPass &addPass) const;
void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
Error addInstSelector(AddMachinePass &) const;
+ void addMachineSSAOptimization(AddMachinePass &) const;
/// Check if a pass is enabled given \p Opt option. The option always
/// overrides defaults if explicitly used. Otherwise its default will be used
``````````
</details>
https://github.com/llvm/llvm-project/pull/111658
More information about the llvm-commits
mailing list