[llvm] [RISCV] Add branch folding before branch relaxation (PR #134760)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 8 10:04:05 PDT 2025


================
@@ -35,13 +33,12 @@ define void @copyprop_after_mbp(i32 %v, ptr %a, ptr %b, ptr %c, ptr %d) {
 ; PROP-NEXT:    sw a0, 0(a2)
 ; PROP-NEXT:    li a0, 1
 ; PROP-NEXT:    sw a0, 0(a1)
-; PROP-NEXT:    li a0, 12
-; PROP-NEXT:    sw a0, 0(a4)
-; PROP-NEXT:    ret
+; PROP-NEXT:    j .LBB0_3
----------------
topperc wrote:

One of the things the branch folding pass does is merging common tails. Tail duplication explicitly creates common tails to reduce the number branch instructions that will be executed. If you run branch folding after tail duplication it will undo explicit tail duplication.

https://github.com/llvm/llvm-project/pull/134760


More information about the llvm-commits mailing list