aboutsummaryrefslogtreecommitdiff
path: root/gcc/haifa-sched.c
diff options
context:
space:
mode:
authorWei Mi <wmi@google.com>2013-11-04 21:41:48 +0000
committerWei Mi <wmi@gcc.gnu.org>2013-11-04 21:41:48 +0000
commit0dc41f28bd2aa4f762b89476fe4885f9c67c16c5 (patch)
treece5d3012d103754d13987152cc5ea59c12303593 /gcc/haifa-sched.c
parentef1b3fda32c08e9bd6977b96e1e619aae3e3726a (diff)
downloadgcc-0dc41f28bd2aa4f762b89476fe4885f9c67c16c5.zip
gcc-0dc41f28bd2aa4f762b89476fe4885f9c67c16c5.tar.gz
gcc-0dc41f28bd2aa4f762b89476fe4885f9c67c16c5.tar.bz2
i386.c (memory_address_length): Extract a part of code to rip_relative_addr_p.
2013-11-04 Wei Mi <wmi@google.com> * gcc/config/i386/i386.c (memory_address_length): Extract a part of code to rip_relative_addr_p. (rip_relative_addr_p): New Function. (ix86_macro_fusion_p): Ditto. (ix86_macro_fusion_pair_p): Ditto. * gcc/config/i386/i386.h: Add new tune features about macro-fusion. * gcc/config/i386/x86-tune.def (DEF_TUNE): Ditto. * gcc/doc/tm.texi: Generated. * gcc/doc/tm.texi.in: Ditto. * gcc/haifa-sched.c (try_group_insn): New Function. (group_insns_for_macro_fusion): Ditto. (sched_init): Call group_insns_for_macro_fusion. * gcc/target.def: Add two hooks: macro_fusion_p and macro_fusion_pair_p. From-SVN: r204369
Diffstat (limited to 'gcc/haifa-sched.c')
-rw-r--r--gcc/haifa-sched.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index aab5748..ab21d0d 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -6519,6 +6519,50 @@ setup_sched_dump (void)
? stderr : dump_file);
}
+/* Try to group comparison and the following conditional jump INSN if
+ they're already adjacent. This is to prevent scheduler from scheduling
+ them apart. */
+
+static void
+try_group_insn (rtx insn)
+{
+ unsigned int condreg1, condreg2;
+ rtx cc_reg_1;
+ rtx prev;
+
+ if (!any_condjump_p (insn))
+ return;
+
+ targetm.fixed_condition_code_regs (&condreg1, &condreg2);
+ cc_reg_1 = gen_rtx_REG (CCmode, condreg1);
+ prev = prev_nonnote_nondebug_insn (insn);
+ if (!reg_referenced_p (cc_reg_1, PATTERN (insn))
+ || !prev
+ || !modified_in_p (cc_reg_1, prev))
+ return;
+
+ /* Different microarchitectures support macro fusions for different
+ combinations of insn pairs. */
+ if (!targetm.sched.macro_fusion_pair_p
+ || !targetm.sched.macro_fusion_pair_p (prev, insn))
+ return;
+
+ SCHED_GROUP_P (insn) = 1;
+}
+
+/* If the last cond jump and the cond register defining insn are consecutive
+ before scheduling, we want them to be in a schedule group. This is good
+ for performance on microarchitectures supporting macro-fusion. */
+
+static void
+group_insns_for_macro_fusion ()
+{
+ basic_block bb;
+
+ FOR_EACH_BB (bb)
+ try_group_insn (BB_END (bb));
+}
+
/* Initialize some global state for the scheduler. This function works
with the common data shared between all the schedulers. It is called
from the scheduler specific initialization routine. */
@@ -6645,6 +6689,11 @@ sched_init (void)
}
curr_state = xmalloc (dfa_state_size);
+
+ /* Group compare and branch insns for macro-fusion. */
+ if (targetm.sched.macro_fusion_p
+ && targetm.sched.macro_fusion_p ())
+ group_insns_for_macro_fusion ();
}
static void haifa_init_only_bb (basic_block, basic_block);