This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Do not apply loop alignment to final block
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 17 Apr 2014 01:29:05 +0200
- Subject: Do not apply loop alignment to final block
- Authentication-results: sourceware.org; auth=none
The alignment code in final.c uses some heuristics to decide what alignment a
block must be given. For the loop alignment, it's:
/* In case block is frequent and reached mostly by non-fallthru edge,
align it. It is most likely a first block of loop. */
An immediate counter-example is a final block (block falling through to the
exit) reached mostly by early returns. There are 8 examples at -O2 in the
gcc.c-torture/compile testsuite on x86-64.
Tested on x86_64-suse-linux, applied on the mainline.
2014-04-16 Eric Botcazou <ebotcazou@adacore.com>
* final.c (compute_alignments): Do not apply loop alignment to a block
falling through to the exit.
--
Eric Botcazou
Index: final.c
===================================================================
--- final.c (revision 209443)
+++ final.c (working copy)
@@ -775,6 +775,8 @@ compute_alignments (void)
/* In case block is frequent and reached mostly by non-fallthru edge,
align it. It is most likely a first block of loop. */
if (has_fallthru
+ && !(single_succ_p (bb)
+ && single_succ (bb) == EXIT_BLOCK_PTR_FOR_FN (cfun))
&& optimize_bb_for_speed_p (bb)
&& branch_frequency + fallthru_frequency > freq_threshold
&& (branch_frequency