Skip to content

Commit 9c5ad62

Browse files
Revert "[RISCV][GISEL] Introduce the RISCVPostLegalizerLowering pass (#108991)"
This reverts commit 6497283. Based on the discussions in #108991 that happened post merge, we have decided to remove this pass in favor of generating `RISCV::G_*` opcodes in the legalizer. We may reconsider moving that code elsewhere in the future so that we can do a better job during generic combines. We don't feel that doing it in instruciton selection is the right decision today. Firstly, it requires us to manually do regbankselect on the newly introduced instructions. Secondly, it is more difficult to test since the test output will contain whatever `RISCV::G_*` instructions select to (instead of `RISCV::G_*`). My personal opinion is that the legalizer pass can be split into an early legalizer and a late legalizer, both before regbankselect. The first legalizer would not introduce target specific generic opcodes and the generic combiner would run after it. The second legalizer would introduce the target specific generic opcodes. I think this approach is better than the lowerer because the legalizer guarantees that whatever we lower to is legal, and apparently because it is more performant at compared to the lowerer (although, I'm not sure how true this is).
1 parent 57b12e8 commit 9c5ad62

File tree

6 files changed

+0
-170
lines changed

6 files changed

+0
-170
lines changed

llvm/lib/Target/RISCV/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ tablegen(LLVM RISCVGenPreLegalizeGICombiner.inc -gen-global-isel-combiner
2424
-combiners="RISCVPreLegalizerCombiner")
2525
tablegen(LLVM RISCVGenPostLegalizeGICombiner.inc -gen-global-isel-combiner
2626
-combiners="RISCVPostLegalizerCombiner")
27-
tablegen(LLVM RISCVGenPostLegalizeGILowering.inc -gen-global-isel-combiner
28-
-combiners="RISCVPostLegalizerLowering")
2927

3028
add_public_tablegen_target(RISCVCommonTableGen)
3129

@@ -66,7 +64,6 @@ add_llvm_target(RISCVCodeGen
6664
GISel/RISCVInstructionSelector.cpp
6765
GISel/RISCVLegalizerInfo.cpp
6866
GISel/RISCVPostLegalizerCombiner.cpp
69-
GISel/RISCVPostLegalizerLowering.cpp
7067
GISel/RISCVO0PreLegalizerCombiner.cpp
7168
GISel/RISCVPreLegalizerCombiner.cpp
7269
GISel/RISCVRegisterBankInfo.cpp

llvm/lib/Target/RISCV/GISel/RISCVPostLegalizerLowering.cpp

Lines changed: 0 additions & 154 deletions
This file was deleted.

llvm/lib/Target/RISCV/RISCV.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ void initializeRISCVO0PreLegalizerCombinerPass(PassRegistry &);
102102

103103
FunctionPass *createRISCVPreLegalizerCombiner();
104104
void initializeRISCVPreLegalizerCombinerPass(PassRegistry &);
105-
106-
FunctionPass *createRISCVPostLegalizerLowering();
107-
void initializeRISCVPostLegalizerLoweringPass(PassRegistry &);
108105
} // namespace llvm
109106

110107
#endif

llvm/lib/Target/RISCV/RISCVCombine.td

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ def RISCVO0PreLegalizerCombiner: GICombiner<
1919
"RISCVO0PreLegalizerCombinerImpl", [optnone_combines]> {
2020
}
2121

22-
// Post-legalization combines which should happen at all optimization levels.
23-
// (E.g. ones that facilitate matching for the selector) For example, matching
24-
// pseudos.
25-
def RISCVPostLegalizerLowering
26-
: GICombiner<"RISCVPostLegalizerLoweringImpl", []> {
27-
}
28-
2922
// Post-legalization combines which are primarily optimizations.
3023
// TODO: Add more combines.
3124
def RISCVPostLegalizerCombiner

llvm/lib/Target/RISCV/RISCVTargetMachine.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTarget() {
111111
initializeRISCVO0PreLegalizerCombinerPass(*PR);
112112
initializeRISCVPreLegalizerCombinerPass(*PR);
113113
initializeRISCVPostLegalizerCombinerPass(*PR);
114-
initializeRISCVPostLegalizerLoweringPass(*PR);
115114
initializeKCFIPass(*PR);
116115
initializeRISCVDeadRegisterDefinitionsPass(*PR);
117116
initializeRISCVMakeCompressibleOptPass(*PR);
@@ -484,7 +483,6 @@ bool RISCVPassConfig::addLegalizeMachineIR() {
484483
void RISCVPassConfig::addPreRegBankSelect() {
485484
if (getOptLevel() != CodeGenOptLevel::None)
486485
addPass(createRISCVPostLegalizerCombiner());
487-
addPass(createRISCVPostLegalizerLowering());
488486
}
489487

490488
bool RISCVPassConfig::addRegBankSelect() {

llvm/test/CodeGen/RISCV/GlobalISel/gisel-commandline-option.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
; ENABLED-NEXT: Legalizer
2424
; ENABLED-O1-NEXT: MachineDominator Tree Construction
2525
; ENABLED-O1-NEXT: RISCVPostLegalizerCombiner
26-
; ENABLED-NEXT: RISCVPostLegalizerLowering
2726
; ENABLED-NEXT: RegBankSelect
2827
; ENABLED-NEXT: Analysis for ComputingKnownBits
2928
; ENABLED-O1-NEXT: Lazy Branch Probability Analysis

0 commit comments

Comments
 (0)