i386.c (decide_alg): Be more conservative about optimizing for size.

* i386.c (decide_alg): Be more conservative about optimizing for size.

	* gcc.target/i386/cold-attribute-1.c: Update testcase.

From-SVN: r140030
This commit is contained in:
Jan Hubicka 2008-09-05 10:44:11 +02:00 committed by Jan Hubicka
parent 84320b0be2
commit 0cf9dcf805
4 changed files with 21 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2008-09-04 Jan Hubicka <jh@suse.cz>
* i386.c (decide_alg): Be more conservative about optimizing for size.
2008-09-04 Ian Lance Taylor <iant@google.com> 2008-09-04 Ian Lance Taylor <iant@google.com>
* varasm.c (narrowing_initializer_constant_valid_p): New * varasm.c (narrowing_initializer_constant_valid_p): New

View File

@ -16994,6 +16994,7 @@ decide_alg (HOST_WIDE_INT count, HOST_WIDE_INT expected_size, bool memset,
int *dynamic_check) int *dynamic_check)
{ {
const struct stringop_algs * algs; const struct stringop_algs * algs;
bool optimize_for_speed;
/* Algorithms using the rep prefix want at least edi and ecx; /* Algorithms using the rep prefix want at least edi and ecx;
additionally, memset wants eax and memcpy wants esi. Don't additionally, memset wants eax and memcpy wants esi. Don't
consider such algorithms if the user has appropriated those consider such algorithms if the user has appropriated those
@ -17008,7 +17009,16 @@ decide_alg (HOST_WIDE_INT count, HOST_WIDE_INT expected_size, bool memset,
&& alg != rep_prefix_8_byte)) && alg != rep_prefix_8_byte))
const struct processor_costs *cost; const struct processor_costs *cost;
cost = optimize_insn_for_size_p () ? &ix86_size_cost : ix86_cost; /* Even if the string operation call is cold, we still might spend a lot
of time processing large blocks. */
if (optimize_function_for_size_p (cfun)
|| (optimize_insn_for_size_p ()
&& expected_size != -1 && expected_size < 256))
optimize_for_speed = false;
else
optimize_for_speed = true;
cost = optimize_for_speed ? ix86_cost : &ix86_size_cost;
*dynamic_check = -1; *dynamic_check = -1;
if (memset) if (memset)
@ -17018,7 +17028,7 @@ decide_alg (HOST_WIDE_INT count, HOST_WIDE_INT expected_size, bool memset,
if (stringop_alg != no_stringop && ALG_USABLE_P (stringop_alg)) if (stringop_alg != no_stringop && ALG_USABLE_P (stringop_alg))
return stringop_alg; return stringop_alg;
/* rep; movq or rep; movl is the smallest variant. */ /* rep; movq or rep; movl is the smallest variant. */
else if (optimize_insn_for_size_p ()) else if (!optimize_for_speed)
{ {
if (!count || (count & 3)) if (!count || (count & 3))
return rep_prefix_usable ? rep_prefix_1_byte : loop_1_byte; return rep_prefix_usable ? rep_prefix_1_byte : loop_1_byte;

View File

@ -1,3 +1,7 @@
2008-09-04 Jan Hubicka <jh@suse.cz>
* gcc.target/i386/cold-attribute-1.c: Update testcase.
2008-09-04 Ian Lance Taylor <iant@google.com> 2008-09-04 Ian Lance Taylor <iant@google.com>
* g++.dg/init/const7.C: New test. * g++.dg/init/const7.C: New test.

View File

@ -10,7 +10,7 @@ my_cold_memset (void *a, int b,int c)
t(void *a,int b,int c) t(void *a,int b,int c)
{ {
if (a) if (a)
my_cold_memset (a,b,c); my_cold_memset (a,b,40);
} }
/* The IF conditional should be predicted as cold and my_cold_memset inlined /* The IF conditional should be predicted as cold and my_cold_memset inlined