Commit e9a8fc23 by Richard Biener Committed by Richard Biener

params.def (PARAM_MAX_COMBINE_INSNS): New.

2014-07-23  Richard Biener  <rguenther@suse.de>

	* params.def (PARAM_MAX_COMBINE_INSNS): New.
	* combine.c: Include statistics.h and params.h.
	(combine_instructions): Guard three and four insn combines
	with max-combine-insns value.  Record statistics for combines
	performed.
	* doc/invoke.texi (max-combine-insns): Document new param.

From-SVN: r212923
parent 322a0b39
2014-07-23 Richard Biener <rguenther@suse.de>
* params.def (PARAM_MAX_COMBINE_INSNS): New.
* combine.c: Include statistics.h and params.h.
(combine_instructions): Guard three and four insn combines
with max-combine-insns value. Record statistics for combines
performed.
* doc/invoke.texi (max-combine-insns): Document new param.
2014-07-23 Roman Gareev <gareevroman@gmail.com> 2014-07-23 Roman Gareev <gareevroman@gmail.com>
* graphite-isl-ast-to-gimple.c: * graphite-isl-ast-to-gimple.c:
......
...@@ -104,6 +104,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -104,6 +104,8 @@ along with GCC; see the file COPYING3. If not see
#include "valtrack.h" #include "valtrack.h"
#include "cgraph.h" #include "cgraph.h"
#include "obstack.h" #include "obstack.h"
#include "statistics.h"
#include "params.h"
/* Number of attempts to combine instructions in this function. */ /* Number of attempts to combine instructions in this function. */
...@@ -1209,6 +1211,7 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -1209,6 +1211,7 @@ combine_instructions (rtx f, unsigned int nregs)
init_reg_last (); init_reg_last ();
setup_incoming_promotions (first); setup_incoming_promotions (first);
last_bb = ENTRY_BLOCK_PTR_FOR_FN (cfun); last_bb = ENTRY_BLOCK_PTR_FOR_FN (cfun);
int max_combine = PARAM_VALUE (PARAM_MAX_COMBINE_INSNS);
FOR_EACH_BB_FN (this_basic_block, cfun) FOR_EACH_BB_FN (this_basic_block, cfun)
{ {
...@@ -1229,8 +1232,9 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -1229,8 +1232,9 @@ combine_instructions (rtx f, unsigned int nregs)
insn = next ? next : NEXT_INSN (insn)) insn = next ? next : NEXT_INSN (insn))
{ {
next = 0; next = 0;
if (NONDEBUG_INSN_P (insn)) if (!NONDEBUG_INSN_P (insn))
{ continue;
while (last_combined_insn while (last_combined_insn
&& INSN_DELETED_P (last_combined_insn)) && INSN_DELETED_P (last_combined_insn))
last_combined_insn = PREV_INSN (last_combined_insn); last_combined_insn = PREV_INSN (last_combined_insn);
...@@ -1255,10 +1259,14 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -1255,10 +1259,14 @@ combine_instructions (rtx f, unsigned int nregs)
if ((next = try_combine (insn, links->insn, NULL_RTX, if ((next = try_combine (insn, links->insn, NULL_RTX,
NULL_RTX, &new_direct_jump_p, NULL_RTX, &new_direct_jump_p,
last_combined_insn)) != 0) last_combined_insn)) != 0)
{
statistics_counter_event (cfun, "two-insn combine", 1);
goto retry; goto retry;
}
/* Try each sequence of three linked insns ending with this one. */ /* Try each sequence of three linked insns ending with this one. */
if (max_combine >= 3)
FOR_EACH_LOG_LINK (links, insn) FOR_EACH_LOG_LINK (links, insn)
{ {
rtx link = links->insn; rtx link = links->insn;
...@@ -1272,8 +1280,11 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -1272,8 +1280,11 @@ combine_instructions (rtx f, unsigned int nregs)
if ((next = try_combine (insn, link, nextlinks->insn, if ((next = try_combine (insn, link, nextlinks->insn,
NULL_RTX, &new_direct_jump_p, NULL_RTX, &new_direct_jump_p,
last_combined_insn)) != 0) last_combined_insn)) != 0)
{
statistics_counter_event (cfun, "three-insn combine", 1);
goto retry; goto retry;
} }
}
#ifdef HAVE_cc0 #ifdef HAVE_cc0
/* Try to combine a jump insn that uses CC0 /* Try to combine a jump insn that uses CC0
...@@ -1338,6 +1349,7 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -1338,6 +1349,7 @@ combine_instructions (rtx f, unsigned int nregs)
/* Try combining an insn with two different insns whose results it /* Try combining an insn with two different insns whose results it
uses. */ uses. */
if (max_combine >= 3)
FOR_EACH_LOG_LINK (links, insn) FOR_EACH_LOG_LINK (links, insn)
for (nextlinks = links->next; nextlinks; for (nextlinks = links->next; nextlinks;
nextlinks = nextlinks->next) nextlinks = nextlinks->next)
...@@ -1345,9 +1357,14 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -1345,9 +1357,14 @@ combine_instructions (rtx f, unsigned int nregs)
nextlinks->insn, NULL_RTX, nextlinks->insn, NULL_RTX,
&new_direct_jump_p, &new_direct_jump_p,
last_combined_insn)) != 0) last_combined_insn)) != 0)
{
statistics_counter_event (cfun, "three-insn combine", 1);
goto retry; goto retry;
}
/* Try four-instruction combinations. */ /* Try four-instruction combinations. */
if (max_combine >= 4)
FOR_EACH_LOG_LINK (links, insn) FOR_EACH_LOG_LINK (links, insn)
{ {
struct insn_link *next1; struct insn_link *next1;
...@@ -1369,7 +1386,10 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -1369,7 +1386,10 @@ combine_instructions (rtx f, unsigned int nregs)
nextlinks->insn, nextlinks->insn,
&new_direct_jump_p, &new_direct_jump_p,
last_combined_insn)) != 0) last_combined_insn)) != 0)
{
statistics_counter_event (cfun, "four-insn combine", 1);
goto retry; goto retry;
}
/* I0, I1 -> I2, I2 -> I3. */ /* I0, I1 -> I2, I2 -> I3. */
for (nextlinks = next1->next; nextlinks; for (nextlinks = next1->next; nextlinks;
nextlinks = nextlinks->next) nextlinks = nextlinks->next)
...@@ -1377,8 +1397,11 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -1377,8 +1397,11 @@ combine_instructions (rtx f, unsigned int nregs)
nextlinks->insn, nextlinks->insn,
&new_direct_jump_p, &new_direct_jump_p,
last_combined_insn)) != 0) last_combined_insn)) != 0)
{
statistics_counter_event (cfun, "four-insn combine", 1);
goto retry; goto retry;
} }
}
for (next1 = links->next; next1; next1 = next1->next) for (next1 = links->next; next1; next1 = next1->next)
{ {
...@@ -1391,16 +1414,22 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -1391,16 +1414,22 @@ combine_instructions (rtx f, unsigned int nregs)
nextlinks->insn, nextlinks->insn,
&new_direct_jump_p, &new_direct_jump_p,
last_combined_insn)) != 0) last_combined_insn)) != 0)
{
statistics_counter_event (cfun, "four-insn combine", 1);
goto retry; goto retry;
}
/* I0 -> I1; I1, I2 -> I3. */ /* I0 -> I1; I1, I2 -> I3. */
FOR_EACH_LOG_LINK (nextlinks, link1) FOR_EACH_LOG_LINK (nextlinks, link1)
if ((next = try_combine (insn, link, link1, if ((next = try_combine (insn, link, link1,
nextlinks->insn, nextlinks->insn,
&new_direct_jump_p, &new_direct_jump_p,
last_combined_insn)) != 0) last_combined_insn)) != 0)
{
statistics_counter_event (cfun, "four-insn combine", 1);
goto retry; goto retry;
} }
} }
}
/* Try this insn with each REG_EQUAL note it links back to. */ /* Try this insn with each REG_EQUAL note it links back to. */
FOR_EACH_LOG_LINK (links, insn) FOR_EACH_LOG_LINK (links, insn)
...@@ -1430,7 +1459,10 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -1430,7 +1459,10 @@ combine_instructions (rtx f, unsigned int nregs)
last_combined_insn); last_combined_insn);
i2mod = NULL_RTX; i2mod = NULL_RTX;
if (next) if (next)
{
statistics_counter_event (cfun, "insn-with-note combine", 1);
goto retry; goto retry;
}
SET_SRC (set) = orig; SET_SRC (set) = orig;
} }
} }
...@@ -1438,11 +1470,10 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -1438,11 +1470,10 @@ combine_instructions (rtx f, unsigned int nregs)
if (!NOTE_P (insn)) if (!NOTE_P (insn))
record_dead_and_set_regs (insn); record_dead_and_set_regs (insn);
retry: retry:
; ;
} }
} }
}
default_rtl_profile (); default_rtl_profile ();
clear_bb_flags (); clear_bb_flags ();
......
...@@ -10006,6 +10006,10 @@ The maximum size measured as number of RTLs that can be recorded in an expressio ...@@ -10006,6 +10006,10 @@ The maximum size measured as number of RTLs that can be recorded in an expressio
in combiner for a pseudo register as last known value of that register. The default in combiner for a pseudo register as last known value of that register. The default
is 10000. is 10000.
@item max-combine-insns
The maximum number of instructions the RTL combiner tries to combine.
The default value is 2 at @option{-Og} and 4 otherwise.
@item integer-share-limit @item integer-share-limit
Small integer constants can use a shared data structure, reducing the Small integer constants can use a shared data structure, reducing the
compiler's memory usage and increasing its speed. This sets the maximum compiler's memory usage and increasing its speed. This sets the maximum
......
...@@ -673,6 +673,11 @@ DEFPARAM(PARAM_MAX_LAST_VALUE_RTL, ...@@ -673,6 +673,11 @@ DEFPARAM(PARAM_MAX_LAST_VALUE_RTL,
"The maximum number of RTL nodes that can be recorded as combiner's last value", "The maximum number of RTL nodes that can be recorded as combiner's last value",
10000, 0, 0) 10000, 0, 0)
DEFPARAM(PARAM_MAX_COMBINE_INSNS,
"max-combine-insns",
"The maximum number of insns combine tries to combine",
4, 2, 4)
/* INTEGER_CST nodes are shared for values [{-1,0} .. N) for /* INTEGER_CST nodes are shared for values [{-1,0} .. N) for
{signed,unsigned} integral types. This determines N. {signed,unsigned} integral types. This determines N.
Experimentation shows 251 to be a good value that generates the Experimentation shows 251 to be a good value that generates the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment