https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70359

--- Comment #43 from rguenther at suse dot de <rguenther at suse dot de> ---
On Mon, 19 Mar 2018, aldyh at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70359
> 
> --- Comment #42 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
> (In reply to Jeffrey A. Law from comment #36)
> > WRT the division removal.  That seems so profitable that a slight increase
> > in codesize is warranted.  So if we fix the other issue  and the source of
> > the remaining codesize regressions is the removal of the division, I would
> > consider this BZ resolved.
> 
> Richi.  Jeff.
> 
> Limiting the single_use with optimize_size as well may give us the best of 
> both
> worlds.  Would you like me to post the [untested] patch below upstream?  With
> this patch code size is even smaller than GCC 5.3.
> 
> I really don't care.  Actually, I'd prefer to do nothing and close the PR 
> ;-). 
> Up to y'all.

I don't like to see plain optimize_size uses in match.pd, so yeah,
just close the PR.

Disclaimer: if we ever need to do sth like that we should wrap it
in sth like optimize_pattern_for_size () to be able to eventually
pick up local profiling info.

> diff --git a/gcc/match.pd b/gcc/match.pd
> index f61c4d7440a..5d29bf62dc9 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -1290,11 +1290,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>  /* X / C1 op C2 into a simple range test.  */
>  (for cmp (simple_comparison)
>   (simplify
> -  (cmp (trunc_div:s @0 INTEGER_CST@1) INTEGER_CST@2)
> +  (cmp (trunc_div:s@3 @0 INTEGER_CST@1) INTEGER_CST@2)
>    (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
>         && integer_nonzerop (@1)
>         && !TREE_OVERFLOW (@1)
> -       && !TREE_OVERFLOW (@2))
> +       && !TREE_OVERFLOW (@2)
> +       && (!optimize_size || single_use (@3)))
>     (with { tree lo, hi; bool neg_overflow;
>            enum tree_code code = fold_div_compare (cmp, @1, @2, &lo, &hi,
>                                                    &neg_overflow); }
> @@ -1456,9 +1457,10 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>  (for cmp (eq ne)
>       ocmp (lt ge)
>   (simplify
> -  (cmp (trunc_div @0 @1) integer_zerop)
> +  (cmp (trunc_div@2 @0 @1) integer_zerop)
>    (if (TYPE_UNSIGNED (TREE_TYPE (@0))
> -       && (VECTOR_TYPE_P (type) || !VECTOR_TYPE_P (TREE_TYPE (@0))))
> +       && (VECTOR_TYPE_P (type) || !VECTOR_TYPE_P (TREE_TYPE (@0)))
> +       && (!optimize_size || single_use (@2)))
>     (ocmp @0 @1))))
> 
>  /* X == C - X can never be true if C is odd.  */
> 
>

Reply via email to