[llvm] [RISCV] Move Machine Copy Propagation Pass before Branch relaxation pass (PR #97261)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 00:23:52 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: None (Yunzezhu94)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/97261.diff
2 Files Affected:
- (modified) llvm/lib/Target/RISCV/RISCVTargetMachine.cpp (+3-3)
- (modified) llvm/test/CodeGen/RISCV/O3-pipeline.ll (+1-1)
``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
index 35d0b3408d09f..100afafb53c62 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,9 @@ 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 1eee62e883cf6..3611d92826235 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
``````````
</details>
https://github.com/llvm/llvm-project/pull/97261
More information about the llvm-commits
mailing list