aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunzezhu94 <93851382+Yunzezhu94@users.noreply.github.com>2024-07-02 09:58:00 +0800
committerGitHub <noreply@github.com>2024-07-02 09:58:00 +0800
commita833fa7d3ef0ca993e7e788b45349c3246e2995e (patch)
treef7102f1a6217cecbda43c5b42f8766fecb1b691a
parenta95c85fba5fde0db8f128cf5564ac333e2b1f90f (diff)
downloadllvm-a833fa7d3ef0ca993e7e788b45349c3246e2995e.zip
llvm-a833fa7d3ef0ca993e7e788b45349c3246e2995e.tar.gz
llvm-a833fa7d3ef0ca993e7e788b45349c3246e2995e.tar.bz2
[RISCV] Move Machine Copy Propagation Pass before Branch relaxation pass (#97261)
Machine Copy Propagation Pass may enlarge branch relaxation distance by breaking generation of compressed insts. This commit moves Machine Copy Propagation Pass before Branch relaxation pass so the results of Branch relaxation pass won't be affected by Machine Copy Propagation Pass.
-rw-r--r--llvm/lib/Target/RISCV/RISCVTargetMachine.cpp5
-rw-r--r--llvm/test/CodeGen/RISCV/O3-pipeline.ll2
2 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
index 35d0b34..f76aef7 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
@@ -497,9 +497,6 @@ void RISCVPassConfig::addPreSched2() {
}
void RISCVPassConfig::addPreEmitPass() {
- addPass(&BranchRelaxationPassID);
- addPass(createRISCVMakeCompressibleOptPass());
-
// TODO: It would potentially be better to schedule copy propagation after
// expanding pseudos (in addPreEmitPass2). However, performing copy
// propagation after the machine outliner (which runs after addPreEmitPass)
@@ -508,6 +505,8 @@ void RISCVPassConfig::addPreEmitPass() {
if (TM->getOptLevel() >= CodeGenOptLevel::Default &&
EnableRISCVCopyPropagation)
addPass(createMachineCopyPropagationPass(true));
+ addPass(&BranchRelaxationPassID);
+ addPass(createRISCVMakeCompressibleOptPass());
}
void RISCVPassConfig::addPreEmitPass2() {
diff --git a/llvm/test/CodeGen/RISCV/O3-pipeline.ll b/llvm/test/CodeGen/RISCV/O3-pipeline.ll
index 1eee62e8..3611d92 100644
--- a/llvm/test/CodeGen/RISCV/O3-pipeline.ll
+++ b/llvm/test/CodeGen/RISCV/O3-pipeline.ll
@@ -182,9 +182,9 @@
; CHECK-NEXT: Insert fentry calls
; CHECK-NEXT: Insert XRay ops
; CHECK-NEXT: Implement the 'patchable-function' attribute
+; CHECK-NEXT: Machine Copy Propagation Pass
; CHECK-NEXT: Branch relaxation pass
; CHECK-NEXT: RISC-V Make Compressible
-; CHECK-NEXT: Machine Copy Propagation Pass
; CHECK-NEXT: Contiguously Lay Out Funclets
; CHECK-NEXT: StackMap Liveness Analysis
; CHECK-NEXT: Live DEBUG_VALUE analysis