[PATCH] Fix canonicalization of addresses

Andrew Haley aph@redhat.com
Wed Jan 7 10:07:00 GMT 2009


Richard Guenther wrote:
> On Wed, Jan 7, 2009 at 7:48 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>>> Indeed.  But we canonicalize u - 2 to u + -2u.  So how about the following
>>> (untested apart from on the testcase)?
>>>
>>> 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
>>>      {
>> This should indeed be equivalent to the first part of the patch.
> 
> Ok, I guess I can agree with that one (it makes it more obvious
> what happens).  I'll bootstrap & test & apply this.  Is there a
> bugzilla I can reference for the problem?

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38751

Andrew.



More information about the Gcc-patches mailing list