This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Handle CONST in a few more places in simplify-rtx.c
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 13 Sep 2009 20:54:24 +0100
- Subject: Re: [PATCH] Handle CONST in a few more places in simplify-rtx.c
- References: <20090911193139.GO14664@tyan-ft48-01.lab.bos.redhat.com>
Jakub Jelinek <jakub@redhat.com> writes:
> While looking at how simplify-rtx.c handles constants wrapped by
> wrap_constant, I've noticed that simplify_unary_operation handles it well,
> but binary/relational/subregs are not.
>
> The following patch fixes that.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux with
> --enable-checking=yes,rtl, ok for trunk?
>
> 2009-09-11 Jakub Jelinek <jakub@redhat.com>
>
> * simplify-rtx.c (simplify_binary_operation): Look through CONST
> trueop[01].
> (simplify_binary_operation_1): For trueop[01] instead of op[01]
> where possible.
> (simplify_relational_operation): Look through CONST op[01].
> (simplify_subreg): Look through CONST op.
>
> --- gcc/simplify-rtx.c.jj 2009-09-03 09:59:40.000000000 +0200
> +++ gcc/simplify-rtx.c 2009-09-11 13:33:26.000000000 +0200
> @@ -1642,6 +1642,10 @@ simplify_binary_operation (enum rtx_code
>
> trueop0 = avoid_constant_pool_reference (op0);
> trueop1 = avoid_constant_pool_reference (op1);
> + if (GET_CODE (trueop0) == CONST)
> + trueop0 = XEXP (trueop0, 0);
> + if (GET_CODE (trueop1) == CONST)
> + trueop1 = XEXP (trueop1, 0);
>
> tem = simplify_const_binary_operation (code, mode, trueop0, trueop1);
> if (tem)
This is probably a dumb question, sorry, but why do you need to
strip the CONSTs? I realise you're at least partly doing it for
consistency with simplify_unary_operation, but I notice that that
function strips the CONST from the original operand ("op")
_before_ calling avoid_constant_pool_reference. Here you instead
strip the CONST from the "trueopX" variable _after_ calling
avoid_constant_pool_reference. Is that a deliberate difference?
>From a quick scan, all uses of trueop{0,1} in simplify_binary_operation_1
and simplify_const_binary_operation appear to be of the form
"rtx_equal_p (trueop0, trueop1)" or "GET_CODE (trueopX) == CONST_FOO".
Stripping CONSTs shouldn't affect those, because it's invalid to have
(const (const_int ...)), (const (const_vector ...)), etc.
Thanks for catching the op1->trueop1 stuff BTW.
Richard