[PATCH] Simplify difference of SYMBOL_REFs (PR target/36090)

Richard Guenther richard.guenther@gmail.com
Thu May 8 16:04:00 GMT 2008


On Sun, May 4, 2008 at 3:31 AM, David Edelsohn <dje@watson.ibm.com> wrote:
>         PPC64 Linux and AIX represent TOC entries in RTL as a difference
>  of SYMBOL_REFs.  References to 128 bit long double values can produce
>  offsets into the doubleword TOC entry.
>
>         forwprop now has become smart enough to recognize more of these
>  addresses.  It tries to simplify the addresses it creates with
>  simplify_plus_minus(), which currently produces non-canonical RTL that
>  PRINT_OPERAND_ADDRESS does not expect, silently producing wrong code.
>
>         simplify_plus_minus() explicitly creates a pairing of an
>  RTX_CONST_OBJ and a CONST_INT, if they were found in the expression, and
>  wraps them in CONST, prior to generating the full simplified expression.
>  The current algorithm does not take into account the expression possibly
>  containing two RTX_CONST_OBJ operands, such as SYMBOL_REFs or LABEL_REFs,
>  that should be grouped together more tightly than CONST_INT.
>
>         Paolo Bonzini suggested the appended patch to group RTX_CONST_OBJ
>  before CONST_INT.
>
>  Bootstrapped and regression tested on powerpc-ibm-aix5.3.0.0.  Testing on
>  x86 also in progress.
>
>  Okay for mainline and 4.3 branch?

This is ok if you also add the ppc specific testcase from the PR.

Thanks,
Richard.

>  Thanks, David
>
>
>  2008-05-04  Paolo Bonzini  <bonzini@gnu.org>
>
>         PR target/36090
>         * simplify-rtx.c (simplify_plus_minus): Create CONST of
>         similar RTX_CONST_OBJ before CONST_INT.
>
>  Index: simplify-rtx.c
>  ===================================================================
>  --- simplify-rtx.c      (revision 134899)
>  +++ simplify-rtx.c      (working copy)
>  @@ -3672,7 +3672,26 @@
>       combination loop to avoid recursion.  Create one manually now.
>       The combination loop should have ensured that there is exactly
>       one CONST_INT, and the sort will have ensured that it is last
>  -     in the array and that any other constant will be next-to-last.  */
>  +     in the array and that any other constant will be next-to-last.
>  +     Group similar RTX_CONST_OBJ first, then CONST_INT.  */
>  +
>  +  if (GET_CODE (ops[n_ops - 1].op) == CONST_INT)
>  +    i = n_ops - 2;
>  +  else
>  +    i = n_ops - 1;
>  +
>  +  if (i >= 1
>  +      && ops[i].neg
>  +      && !ops[i - 1].neg
>  +      && CONSTANT_P (ops[i].op)
>  +      && GET_CODE (ops[i].op) == GET_CODE (ops[i - 1].op))
>  +    {
>  +      ops[i - 1].op = gen_rtx_MINUS (mode, ops[i - 1].op, ops[i].op);
>  +      ops[i - 1].op = gen_rtx_CONST (mode, ops[i - 1].op);
>  +      if (i < n_ops - 1)
>  +       ops[i] = ops[i + 1];
>  +      n_ops--;
>  +    }
>
>    if (n_ops > 1
>        && GET_CODE (ops[n_ops - 1].op) == CONST_INT
>



More information about the Gcc-patches mailing list