Summary: | Basic block re-ordering unconditionally disabled for Os | ||
---|---|---|---|
Product: | gcc | Reporter: | Rahul Kharche <rkharche> |
Component: | rtl-optimization | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | enhancement | CC: | gcc-bugs, icera-sdkteam-gnu, stevenb.gcc |
Priority: | P3 | Keywords: | missed-optimization |
Version: | 4.4.1 | ||
Target Milestone: | 6.0 | ||
Host: | i686-pc-linux-gnu | Target: | i686-pc-linux-gnu |
Build: | i686-pc-linux-gnu | Known to work: | |
Known to fail: | Last reconfirmed: | 2010-03-26 12:24:22 |
Description
Rahul Kharche
2010-03-25 11:18:46 UTC
It's disabled on a function-by-function basis which looks valid. No, the user should be able to say "do this" and then the compiler should do so. Right now the flag to enable BB-reorder has no effect at -Os, and that is a bug. The following test in 'rest_of_handle_reorder_blocks' if ((flag_reorder_blocks || flag_reorder_blocks_and_partition) && optimize_function_for_speed_p (cfun)) { ... } suggests when optimize_size is true reordering would not run, even if I were to use -freorder-blocks as a command line option or a function attribute? I also just noticed PR41396 is related. Well, it's like you say -ftree-pre but a partial redundancy is not removed because it was on a cold path. bb-reorder should probably take into account size/speed optimization in more general and the optimize_function_for_speed_p predicate doesn't properly honor attribute(("hot")) with -Os, but I can't see anything wrong with trying to optimize cold parts of a program for size (and no, we do not have a flag to override this). Hmm, I think this changed recently (within the last 2 years). Fixed for GCC 6 by: r228318 | segher | 2015-09-30 23:38:24 -0700 (Wed, 30 Sep 2015) | 23 lines bb-reorder: Add -freorder-blocks-algorithm= and wire it up This adds an -freorder-blocks-algorithm=[simple|stc] flag, with "simple" as default. For -O2 and up (except -Os) it is switched to "stc" instead. Targets that never want STC can override this. This changes -freorder-blocks to be on at -O1 and up (was -O2 and up). In effect, the changes are for -O1 (which now gets "simple" instead of nothing), -Os (which now gets "simple" instead of "stc", since STC results in much bigger code), and for targets that wish to never use STC (not in this patch though). 2015-09-23 Segher Boessenkool <segher@kernel.crashing.org> * bb-reorder.c (reorder_basic_blocks): Use the algorithm selected with flag_reorder_blocks_algorithm. * common.opt (freorder-blocks-algorithm=): New flag. (reorder_blocks_algorithm): New enum. * flag-types.h (reorder_blocks_algorithm): New enum. * opts.c (default_options_table): Use -freorder-blocks at -O1 and up, and -freorder-blocks-algorithm=stc at -O2 and up (not at -Os). |