[AMDGPU][NewPM] Port SIFixVGPRCopies to NPM (#123592)
Extends NPM pipeline support till PostRegAlloc passes (greedy is in the works)
This commit is contained in:
parent
b6b18f1eb8
commit
9b6e8df896
@ -177,7 +177,7 @@ extern char &SIShrinkInstructionsLegacyID;
|
||||
void initializeSIFixSGPRCopiesLegacyPass(PassRegistry &);
|
||||
extern char &SIFixSGPRCopiesLegacyID;
|
||||
|
||||
void initializeSIFixVGPRCopiesPass(PassRegistry &);
|
||||
void initializeSIFixVGPRCopiesLegacyPass(PassRegistry &);
|
||||
extern char &SIFixVGPRCopiesID;
|
||||
|
||||
void initializeSILowerWWMCopiesPass(PassRegistry &);
|
||||
|
@ -99,6 +99,7 @@ FUNCTION_PASS_WITH_PARAMS(
|
||||
MACHINE_FUNCTION_PASS("amdgpu-isel", AMDGPUISelDAGToDAGPass(*this))
|
||||
MACHINE_FUNCTION_PASS("si-fix-sgpr-copies", SIFixSGPRCopiesPass())
|
||||
MACHINE_FUNCTION_PASS("si-i1-copies", SILowerI1CopiesPass())
|
||||
MACHINE_FUNCTION_PASS("si-fix-vgpr-copies", SIFixVGPRCopiesPass())
|
||||
MACHINE_FUNCTION_PASS("si-fold-operands", SIFoldOperandsPass());
|
||||
MACHINE_FUNCTION_PASS("gcn-dpp-combine", GCNDPPCombinePass())
|
||||
MACHINE_FUNCTION_PASS("si-load-store-opt", SILoadStoreOptimizerPass())
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "R600.h"
|
||||
#include "R600TargetMachine.h"
|
||||
#include "SIFixSGPRCopies.h"
|
||||
#include "SIFixVGPRCopies.h"
|
||||
#include "SIFoldOperands.h"
|
||||
#include "SILoadStoreOptimizer.h"
|
||||
#include "SILowerControlFlow.h"
|
||||
@ -486,7 +487,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() {
|
||||
initializeAMDGPUMarkLastScratchLoadPass(*PR);
|
||||
initializeSILowerSGPRSpillsLegacyPass(*PR);
|
||||
initializeSIFixSGPRCopiesLegacyPass(*PR);
|
||||
initializeSIFixVGPRCopiesPass(*PR);
|
||||
initializeSIFixVGPRCopiesLegacyPass(*PR);
|
||||
initializeSIFoldOperandsLegacyPass(*PR);
|
||||
initializeSIPeepholeSDWALegacyPass(*PR);
|
||||
initializeSIShrinkInstructionsLegacyPass(*PR);
|
||||
@ -2107,7 +2108,7 @@ void AMDGPUCodeGenPassBuilder::addMachineSSAOptimization(
|
||||
}
|
||||
|
||||
void AMDGPUCodeGenPassBuilder::addPostRegAlloc(AddMachinePass &addPass) const {
|
||||
// addPass(SIFixVGPRCopiesID);
|
||||
addPass(SIFixVGPRCopiesPass());
|
||||
if (TM.getOptLevel() > CodeGenOptLevel::None)
|
||||
addPass(SIOptimizeExecMaskingPass());
|
||||
Base::addPostRegAlloc(addPass);
|
||||
|
@ -11,6 +11,7 @@
|
||||
///
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "SIFixVGPRCopies.h"
|
||||
#include "AMDGPU.h"
|
||||
#include "GCNSubtarget.h"
|
||||
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
||||
@ -22,13 +23,12 @@ using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
class SIFixVGPRCopies : public MachineFunctionPass {
|
||||
class SIFixVGPRCopiesLegacy : public MachineFunctionPass {
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
public:
|
||||
SIFixVGPRCopies() : MachineFunctionPass(ID) {
|
||||
initializeSIFixVGPRCopiesPass(*PassRegistry::getPassRegistry());
|
||||
SIFixVGPRCopiesLegacy() : MachineFunctionPass(ID) {
|
||||
initializeSIFixVGPRCopiesLegacyPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
@ -41,15 +41,31 @@ public:
|
||||
StringRef getPassName() const override { return "SI Fix VGPR copies"; }
|
||||
};
|
||||
|
||||
class SIFixVGPRCopies {
|
||||
public:
|
||||
bool run(MachineFunction &MF);
|
||||
};
|
||||
|
||||
} // End anonymous namespace.
|
||||
|
||||
INITIALIZE_PASS(SIFixVGPRCopies, DEBUG_TYPE, "SI Fix VGPR copies", false, false)
|
||||
INITIALIZE_PASS(SIFixVGPRCopiesLegacy, DEBUG_TYPE, "SI Fix VGPR copies", false,
|
||||
false)
|
||||
|
||||
char SIFixVGPRCopies::ID = 0;
|
||||
char SIFixVGPRCopiesLegacy::ID = 0;
|
||||
|
||||
char &llvm::SIFixVGPRCopiesID = SIFixVGPRCopies::ID;
|
||||
char &llvm::SIFixVGPRCopiesID = SIFixVGPRCopiesLegacy::ID;
|
||||
|
||||
bool SIFixVGPRCopies::runOnMachineFunction(MachineFunction &MF) {
|
||||
PreservedAnalyses SIFixVGPRCopiesPass::run(MachineFunction &MF,
|
||||
MachineFunctionAnalysisManager &) {
|
||||
SIFixVGPRCopies().run(MF);
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
bool SIFixVGPRCopiesLegacy::runOnMachineFunction(MachineFunction &MF) {
|
||||
return SIFixVGPRCopies().run(MF);
|
||||
}
|
||||
|
||||
bool SIFixVGPRCopies::run(MachineFunction &MF) {
|
||||
const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
|
||||
const SIRegisterInfo *TRI = ST.getRegisterInfo();
|
||||
const SIInstrInfo *TII = ST.getInstrInfo();
|
||||
|
22
llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h
Normal file
22
llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h
Normal file
@ -0,0 +1,22 @@
|
||||
//===- SIFixVGPRCopies.h ----------------------------------------*- C++- *-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_LIB_TARGET_AMDGPU_SIFIXVGPRCOPIES_H
|
||||
#define LLVM_LIB_TARGET_AMDGPU_SIFIXVGPRCOPIES_H
|
||||
|
||||
#include "llvm/CodeGen/MachinePassManager.h"
|
||||
|
||||
namespace llvm {
|
||||
class SIFixVGPRCopiesPass : public PassInfoMixin<SIFixVGPRCopiesPass> {
|
||||
public:
|
||||
PreservedAnalyses run(MachineFunction &MF,
|
||||
MachineFunctionAnalysisManager &MFAM);
|
||||
};
|
||||
} // namespace llvm
|
||||
|
||||
#endif // LLVM_LIB_TARGET_AMDGPU_SIFIXVGPRCOPIES_H
|
@ -1,4 +1,6 @@
|
||||
# RUN: llc -mtriple=amdgcn -start-after=greedy -disable-copyprop -stop-after=si-optimize-exec-masking -o - %s | FileCheck %s
|
||||
# RUN: llc -mtriple=amdgcn -passes=si-fix-vgpr-copies,si-optimize-exec-masking -o - %s | FileCheck %s
|
||||
|
||||
# Check that we first do all vector instructions and only then change exec
|
||||
# CHECK-DAG: COPY $vgpr10_vgpr11
|
||||
# CHECK-DAG: COPY $vgpr12_vgpr13
|
||||
|
Loading…
x
Reference in New Issue
Block a user