Skip to content

Commit 3d2fee4

Browse files
[RISCV] Add branch folding before branch relaxation
This is a follow-up patch to PR llvm#133256. This patch adds the branch folding pass after the newly added late optimization pass for riscv, which reduces code size in all SPEC benchmarks (except libm). The improvements are: 500.perlbench_r (-3.37%), 544.nab_r (-3.06%), 557.xz_r (-2.82%), 523.xalancbmk_r (-2.64%), 520.omnetpp_r (-2.34%), 531.deepsjeng_r (-2.27%), 502.gcc_r (-2.19%), 526.blender_r (-2.11%), 538.imagick_r (-2.03%), 505.mcf_r (-1.82%), 541.leela_r (-1.74%), 511.povray_r (-1.62%), 510.parest_r (-1.62%), 508.namd_r (-1.57%), 525.x264_r (-1.47%). Geo mean is -2.07%. Some caveats: * On llvm#131728 I mentioned a 7% improvement on execution time of xz, but that's no longer the case. I went back and also tried to reproduce the result with the code from llvm#131728 and couldn't. Now the results from that PR and this one are the same: an overall code size reduction but no exec time improvements. * The root cause of the large number is not yet clear for me. I'm still investigating it.
1 parent 50ea777 commit 3d2fee4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6412
-9867
lines changed

llvm/lib/Target/RISCV/RISCVTargetMachine.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ void RISCVPassConfig::addPreEmitPass() {
568568
addPass(createMachineCopyPropagationPass(true));
569569
if (TM->getOptLevel() >= CodeGenOptLevel::Default)
570570
addPass(createRISCVLateBranchOptPass());
571+
addPass(&BranchFolderPassID);
571572
addPass(&BranchRelaxationPassID);
572573
addPass(createRISCVMakeCompressibleOptPass());
573574
}

0 commit comments

Comments
 (0)