From: Segher Boessenkool <segher@kernel.crashing.org>
To: gcc-patches@gcc.gnu.org
Cc: Segher Boessenkool <segher@kernel.crashing.org>
Subject: [PATCH 3/4] bb-reorder: Add -freorder-blocks-algorithm= and wire it up
Date: Wed, 23 Sep 2015 23:01:00 -0000 [thread overview]
Message-ID: <a1846b548ba9345fde9fab897271215dc03b6acf.1443028412.git.segher@kernel.crashing.org> (raw)
In-Reply-To: <cover.1443028412.git.segher@kernel.crashing.org>
In-Reply-To: <cover.1443028412.git.segher@kernel.crashing.org>
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).
---
gcc/bb-reorder.c | 17 +++++++++++++----
gcc/common.opt | 13 +++++++++++++
gcc/flag-types.h | 7 +++++++
gcc/opts.c | 4 +++-
4 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index 40e9e50..e09f344 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -2429,10 +2429,19 @@ reorder_basic_blocks (void)
set_edge_can_fallthru_flag ();
mark_dfs_back_edges ();
- if (1)
- reorder_basic_blocks_software_trace_cache ();
- else
- reorder_basic_blocks_simple ();
+ switch (flag_reorder_blocks_algorithm)
+ {
+ case REORDER_BLOCKS_ALGORITHM_SIMPLE:
+ reorder_basic_blocks_simple ();
+ break;
+
+ case REORDER_BLOCKS_ALGORITHM_STC:
+ reorder_basic_blocks_software_trace_cache ();
+ break;
+
+ default:
+ gcc_unreachable ();
+ }
relink_block_chain (/*stay_in_cfglayout_mode=*/true);
diff --git a/gcc/common.opt b/gcc/common.opt
index 94d1d88..b0f70fb 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1910,6 +1910,19 @@ freorder-blocks
Common Report Var(flag_reorder_blocks) Optimization
Reorder basic blocks to improve code placement
+freorder-blocks-algorithm=
+Common Joined RejectNegative Enum(reorder_blocks_algorithm) Var(flag_reorder_blocks_algorithm) Init(REORDER_BLOCKS_ALGORITHM_SIMPLE) Optimization
+-freorder-blocks-algorithm=[simple|stc] Set the used basic block reordering algorithm
+
+Enum
+Name(reorder_blocks_algorithm) Type(enum reorder_blocks_algorithm) UnknownError(unknown basic block reordering algorithm %qs)
+
+EnumValue
+Enum(reorder_blocks_algorithm) String(simple) Value(REORDER_BLOCKS_ALGORITHM_SIMPLE)
+
+EnumValue
+Enum(reorder_blocks_algorithm) String(stc) Value(REORDER_BLOCKS_ALGORITHM_STC)
+
freorder-blocks-and-partition
Common Report Var(flag_reorder_blocks_and_partition) Optimization
Reorder basic blocks and partition into hot and cold sections
diff --git a/gcc/flag-types.h b/gcc/flag-types.h
index ac9ca0b..6301cea 100644
--- a/gcc/flag-types.h
+++ b/gcc/flag-types.h
@@ -109,6 +109,13 @@ enum stack_reuse_level
SR_ALL
};
+/* The algorithm used for basic block reordering. */
+enum reorder_blocks_algorithm
+{
+ REORDER_BLOCKS_ALGORITHM_SIMPLE,
+ REORDER_BLOCKS_ALGORITHM_STC
+};
+
/* The algorithm used for the integrated register allocator (IRA). */
enum ira_algorithm
{
diff --git a/gcc/opts.c b/gcc/opts.c
index f1a9acd..786fd3a 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -441,6 +441,7 @@ static const struct default_options default_options_table[] =
{ OPT_LEVELS_1_PLUS, OPT_fipa_reference, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fipa_profile, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fmerge_constants, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_freorder_blocks, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fshrink_wrap, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fsplit_wide_types, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_ftree_ccp, NULL, 1 },
@@ -483,7 +484,8 @@ static const struct default_options default_options_table[] =
#endif
{ OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 },
- { OPT_LEVELS_2_PLUS, OPT_freorder_blocks, NULL, 1 },
+ { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_freorder_blocks_algorithm_, NULL,
+ REORDER_BLOCKS_ALGORITHM_STC },
{ OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_ftree_builtin_call_dce, NULL, 1 },
--
1.8.1.4
next prev parent reply other threads:[~2015-09-23 22:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-23 22:09 [PATCH 0/4] bb-reorder: Add the "simple" algorithm Segher Boessenkool
2015-09-23 22:09 ` [PATCH 1/4] bb-reorder: Split out STC Segher Boessenkool
2015-09-24 16:12 ` Steven Bosscher
2015-09-23 22:10 ` [PATCH 2/4] bb-reorder: Add the "simple" algorithm Segher Boessenkool
2015-09-24 11:13 ` Bernd Schmidt
2015-09-24 13:48 ` Segher Boessenkool
2015-09-24 15:19 ` Segher Boessenkool
2015-09-24 16:35 ` Steven Bosscher
2015-09-24 17:22 ` Segher Boessenkool
2015-09-25 14:31 ` [PATCH 2/4 v2] " Segher Boessenkool
2015-09-25 16:09 ` Peter Bergner
2015-09-25 16:15 ` Segher Boessenkool
2015-09-29 13:19 ` Bernd Schmidt
2015-09-23 23:01 ` Segher Boessenkool [this message]
2015-09-24 11:00 ` [PATCH 3/4] bb-reorder: Add -freorder-blocks-algorithm= and wire it up Bernd Schmidt
2015-09-24 14:06 ` Segher Boessenkool
2015-09-24 15:21 ` Andi Kleen
2015-09-24 15:49 ` Segher Boessenkool
2015-09-24 17:16 ` Segher Boessenkool
[not found] ` <56377569.7010904@arm.com>
2015-11-02 15:14 ` Alan Lawrence
2015-11-02 21:04 ` Segher Boessenkool
2015-09-23 23:36 ` [PATCH 4/4] bb-reorder: Documentation updates Segher Boessenkool
2015-09-24 10:33 ` [PATCH 0/4] bb-reorder: Add the "simple" algorithm Bernd Schmidt
2015-09-24 13:32 ` Segher Boessenkool
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a1846b548ba9345fde9fab897271215dc03b6acf.1443028412.git.segher@kernel.crashing.org \
--to=segher@kernel.crashing.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).