aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>2025-08-21 21:37:59 -0700
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>2025-08-28 08:34:00 -0700
commit6750f5902c600907a56b9a72b4bae7d9762515c9 (patch)
treeeda98feaed3f14a4ff67436e3a5e8cb17de10172
parent0545b6507e901c91df9bbe778b7ebf7d0fca242f (diff)
downloadgcc-6750f5902c600907a56b9a72b4bae7d9762515c9.zip
gcc-6750f5902c600907a56b9a72b4bae7d9762515c9.tar.gz
gcc-6750f5902c600907a56b9a72b4bae7d9762515c9.tar.bz2
passes: Move cleanup_eh before first tailr [PR115201]
So the current pass order is: ``` NEXT_PASS (pass_tail_recursion); NEXT_PASS (pass_if_to_switch); NEXT_PASS (pass_convert_switch); NEXT_PASS (pass_cleanup_eh); ``` But nothing in if_to_switch nor convert_switch will change the IR such that cleanup eh will take into account. tail_recusion benifits the most by not having "almost" empty landing pads. This order was originally done when cleanup_eh was added in r0-92178-ga8da523f8a442f but it looks like it was just done just before inlining rather than thinking it could improve passes before hand. An example where this helps is PR 115201 where we have: ``` ;; basic block 5, loop depth 0, maybe hot ;; prev block 4, next block 6, flags: (NEW, REACHABLE, VISITED) ;; pred: 4 (TRUE_VALUE,EXECUTABLE) [LP 1] # .MEM_19 = VDEF <.MEM_45> # USE = nonlocal escaped # CLB = nonlocal escaped D.4770 = _Z12binarySearchIi2itIiEET0_RKT_S2_S2_D.4690 (item_15(D), startD.4711, midD.4717); goto <bb 7>; [INV] ;; succ: 8 (EH,EXECUTABLE) ;; 7 (FALLTHRU,EXECUTABLE) ... ;; basic block 8, loop depth 0, maybe hot ;; prev block 7, next block 1, flags: (NEW, REACHABLE, VISITED) ;; pred: 5 (EH,EXECUTABLE) ;; 6 (EH,EXECUTABLE) # .MEM_7 = PHI <.MEM_19(5), .MEM_18(6)> <L6>: [LP 1] # .MEM_20 = VDEF <.MEM_7> midD.4717 ={v} {CLOBBER(eos)}; resx 1 ;; succ: ``` As you can see the empty landing pad should be able to remove away and then a tail recursion can happen. Bootstrapped and tested x86_64-linux-gnu. PR tree-optimization/115201 gcc/ChangeLog: * passes.def: Move cleanup_eh before first tail_recursion. Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
-rw-r--r--gcc/passes.def4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/passes.def b/gcc/passes.def
index 68ce53b..c870170 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -97,10 +97,12 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_dse);
NEXT_PASS (pass_cd_dce, false /* update_address_taken_p */, true /* remove_unused_locals */);
NEXT_PASS (pass_phiopt, true /* early_p */);
+ /* Cleanup eh is done before tail recusision to remove empty (only clobbers)
+ finally blocks which would block tail recursion. */
+ NEXT_PASS (pass_cleanup_eh);
NEXT_PASS (pass_tail_recursion);
NEXT_PASS (pass_if_to_switch);
NEXT_PASS (pass_convert_switch);
- NEXT_PASS (pass_cleanup_eh);
NEXT_PASS (pass_sccopy);
NEXT_PASS (pass_profile);
NEXT_PASS (pass_local_pure_const);