Update expanders to use optimize_insn_for_size predicate.
Jan Hubicka
jh@suse.cz
Sat Aug 2 19:16:00 GMT 2008
Hi,
this patch replace some of optimize_size tests by
optimize_insn_for_speed_p predicate so we can make decisions on per-BB
granuality.
Honza
* optabs.c (expand_binop, expand_builtin_pow, expand_builtin_powi,
expand_builtin_strcat): Upse optimize_insn_for_speed predicate.
* expmed.c (expand_smod_pow2): Likewise.
Index: optabs.c
===================================================================
*** optabs.c (revision 138551)
--- optabs.c (working copy)
*************** expand_binop (enum machine_mode mode, op
*** 1786,1792 ****
if ((binoptab == lshr_optab || binoptab == ashl_optab
|| binoptab == ashr_optab)
&& mclass == MODE_INT
! && (GET_CODE (op1) == CONST_INT || !optimize_size)
&& GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD
&& optab_handler (binoptab, word_mode)->insn_code != CODE_FOR_nothing
&& optab_handler (ashl_optab, word_mode)->insn_code != CODE_FOR_nothing
--- 1786,1792 ----
if ((binoptab == lshr_optab || binoptab == ashl_optab
|| binoptab == ashr_optab)
&& mclass == MODE_INT
! && (GET_CODE (op1) == CONST_INT || optimize_insn_for_speed_p ())
&& GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD
&& optab_handler (binoptab, word_mode)->insn_code != CODE_FOR_nothing
&& optab_handler (ashl_optab, word_mode)->insn_code != CODE_FOR_nothing
Index: builtins.c
===================================================================
*** builtins.c (revision 138551)
--- builtins.c (working copy)
*************** expand_builtin_pow (tree exp, rtx target
*** 2911,2917 ****
if (real_identical (&c, &cint)
&& ((n >= -1 && n <= 2)
|| (flag_unsafe_math_optimizations
! && !optimize_size
&& powi_cost (n) <= POWI_MAX_MULTS)))
{
op = expand_expr (arg0, subtarget, VOIDmode, EXPAND_NORMAL);
--- 2911,2917 ----
if (real_identical (&c, &cint)
&& ((n >= -1 && n <= 2)
|| (flag_unsafe_math_optimizations
! && optimize_insn_for_speed_p ()
&& powi_cost (n) <= POWI_MAX_MULTS)))
{
op = expand_expr (arg0, subtarget, VOIDmode, EXPAND_NORMAL);
*************** expand_builtin_pow (tree exp, rtx target
*** 2935,2941 ****
real_from_integer (&cint, VOIDmode, n, n < 0 ? -1 : 0, 0);
if (real_identical (&c2, &cint)
&& ((flag_unsafe_math_optimizations
! && !optimize_size
&& powi_cost (n/2) <= POWI_MAX_MULTS)
|| n == 1))
{
--- 2935,2941 ----
real_from_integer (&cint, VOIDmode, n, n < 0 ? -1 : 0, 0);
if (real_identical (&c2, &cint)
&& ((flag_unsafe_math_optimizations
! && optimize_insn_for_speed_p ()
&& powi_cost (n/2) <= POWI_MAX_MULTS)
|| n == 1))
{
*************** expand_builtin_pow (tree exp, rtx target
*** 2980,2986 ****
real_arithmetic (&c2, RDIV_EXPR, &cint, &dconst3);
real_convert (&c2, mode, &c2);
if (real_identical (&c2, &c)
! && ((!optimize_size
&& powi_cost (n/3) <= POWI_MAX_MULTS)
|| n == 1))
{
--- 2980,2986 ----
real_arithmetic (&c2, RDIV_EXPR, &cint, &dconst3);
real_convert (&c2, mode, &c2);
if (real_identical (&c2, &c)
! && ((optimize_insn_for_speed_p ()
&& powi_cost (n/3) <= POWI_MAX_MULTS)
|| n == 1))
{
*************** expand_builtin_powi (tree exp, rtx targe
*** 3042,3048 ****
if ((TREE_INT_CST_HIGH (arg1) == 0
|| TREE_INT_CST_HIGH (arg1) == -1)
&& ((n >= -1 && n <= 2)
! || (! optimize_size
&& powi_cost (n) <= POWI_MAX_MULTS)))
{
op0 = expand_expr (arg0, subtarget, VOIDmode, EXPAND_NORMAL);
--- 3042,3048 ----
if ((TREE_INT_CST_HIGH (arg1) == 0
|| TREE_INT_CST_HIGH (arg1) == -1)
&& ((n >= -1 && n <= 2)
! || (optimize_insn_for_speed_p ()
&& powi_cost (n) <= POWI_MAX_MULTS)))
{
op0 = expand_expr (arg0, subtarget, VOIDmode, EXPAND_NORMAL);
*************** expand_builtin_strcat (tree fndecl, tree
*** 4464,4470 ****
if (p && *p == '\0')
return expand_expr (dst, target, mode, EXPAND_NORMAL);
! if (!optimize_size)
{
/* See if we can store by pieces into (dst + strlen(dst)). */
tree newsrc, newdst,
--- 4464,4470 ----
if (p && *p == '\0')
return expand_expr (dst, target, mode, EXPAND_NORMAL);
! if (optimize_insn_for_speed_p ())
{
/* See if we can store by pieces into (dst + strlen(dst)). */
tree newsrc, newdst,
Index: expmed.c
===================================================================
*** expmed.c (revision 138551)
--- expmed.c (working copy)
*************** expand_smod_pow2 (enum machine_mode mode
*** 3487,3493 ****
/* Avoid conditional branches when they're expensive. */
if (BRANCH_COST >= 2
! && !optimize_size)
{
rtx signmask = emit_store_flag (result, LT, op0, const0_rtx,
mode, 0, -1);
--- 3487,3493 ----
/* Avoid conditional branches when they're expensive. */
if (BRANCH_COST >= 2
! && optimize_insn_for_speed_p ())
{
rtx signmask = emit_store_flag (result, LT, op0, const0_rtx,
mode, 0, -1);
More information about the Gcc-patches
mailing list