This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix canonicalization of addresses


> Index: fold-const.c
> ===================================================================
> --- fold-const.c	(revision 143138)
> +++ fold-const.c	(working copy)
> @@ -7439,7 +7439,17 @@ fold_plusminus_mult_expr (enum tree_code
>    else if (TREE_CODE (arg1) == INTEGER_CST)
>      {
>        arg10 = build_one_cst (type);
> -      arg11 = arg1;
> +      /* As we canonicalize A - 2 to A + -2 get rid of that sign for
> +         the purpose of this canonicalization.  */
> +      if (TREE_INT_CST_HIGH (arg1) == -1
> +	  && negate_expr_p (arg1)
> +	  && code == PLUS_EXPR)
> +	{
> +	  arg11 = negate_expr (arg1);
> +	  code = MINUS_EXPR;
> +	}
> +      else
> +	arg11 = arg1;
>      }
>    else
>      {

Note that this has also changed the canonicalization of X*n + (-n) with n not 
a power of 2.  Previously it was left untouched; now it's canonicalized into
(X + -1) * n, like its positive counterpart.  Which ends up having a visible 
detrimental effect for my own testcase at -O2. :-(

-- 
Eric Botcazou


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]