On 8/13/19 2:33 AM, Robin Dapp wrote:
> We would like to simplify code like
> (larger_type)(var + const1) + const2
> to
> (larger_type)(var + combined_const1_const2)
> when we know that no overflow happens.
> ---
> gcc/match.pd | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 101 insertions(+)
>
> diff --git a/gcc/match.pd b/gcc/match.pd
> index 0317bc704f7..94400529ad8 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -2020,6 +2020,107 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
> (if (cst && !TREE_OVERFLOW (cst))
> (plus { cst; } @0))))
>
> +/* ((T)(A + CST1)) + CST2 -> (T)(A) + CST */
Do you want to handle MINUS? What about POINTER_PLUS_EXPR?
Richi and Marc are better suited to review the guts of this change than
I am.
I though we had these transformations in fold-const.c and I was going to
suggest removing them as a part of this patch. *But* I can't seem to
find them.
Jeff