diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 036e97bd92cc..934eb02afdf7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2008-09-04 Jan Hubicka + + * i386.c (decide_alg): Be more conservative about optimizing for size. + 2008-09-04 Ian Lance Taylor * varasm.c (narrowing_initializer_constant_valid_p): New diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 2c016328e4c0..e847a11ea3a0 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -16994,6 +16994,7 @@ decide_alg (HOST_WIDE_INT count, HOST_WIDE_INT expected_size, bool memset, int *dynamic_check) { const struct stringop_algs * algs; + bool optimize_for_speed; /* Algorithms using the rep prefix want at least edi and ecx; additionally, memset wants eax and memcpy wants esi. Don't 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)) 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; 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)) return stringop_alg; /* 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)) return rep_prefix_usable ? rep_prefix_1_byte : loop_1_byte; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 35c2f992e516..827968a6594b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-09-04 Jan Hubicka + + * gcc.target/i386/cold-attribute-1.c: Update testcase. + 2008-09-04 Ian Lance Taylor * g++.dg/init/const7.C: New test. diff --git a/gcc/testsuite/gcc.target/i386/cold-attribute-1.c b/gcc/testsuite/gcc.target/i386/cold-attribute-1.c index 22615b38790f..db81ee837adf 100644 --- a/gcc/testsuite/gcc.target/i386/cold-attribute-1.c +++ b/gcc/testsuite/gcc.target/i386/cold-attribute-1.c @@ -10,7 +10,7 @@ my_cold_memset (void *a, int b,int c) t(void *a,int b,int c) { 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