This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR 37363 follow-on 1: avoid gen_rtx_CONST call in cse.c:fold_rtx
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org, rdsandiford at googlemail dot com
- Date: Tue, 11 Nov 2008 09:30:30 -0600
- Subject: Re: PR 37363 follow-on 1: avoid gen_rtx_CONST call in cse.c:fold_rtx
- References: <87fxlzma7t.fsf@firetop.home>
On Mon, Nov 10, 2008 at 5:29 PM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> Although this patch isn't strictly necessary to fix PR 37363, the
> comment suggests that we might in future create (const (minus ...))s
> in fold_rtx. Since we don't want to do that, I'd like to apply this
> patch at the same time as the main one.
>
> The code I'm removing should be dead: simplify_unary_operation should
> already know when the result can be treated as a CONST.
>
> Bootstrapped & regression-tested on x86_64-linux-gnu. Also tested
> by comparing the before and after assembly output for:
>
> gcc.c-torture gcc.dg g++.dg
>
> on these targets:
>
> powerpc-darwin powerpc64-darwin i386-darwin x86_64-darwin
> powerpc-linux-gnu powerpc64-linux-gnu powerpc-ibm-aix5.3.0
>
> using the options "-O2 -fpic". The output was the same.
> OK to install?
Ok.
Thanks,
Richard.
> Richard
>
>
> gcc/
> * cse.c (fold_rtx): Remove redundant gen_rtx_CONST.
>
> Index: gcc/cse.c
> ===================================================================
> --- gcc/cse.c 2008-11-10 23:00:17.000000000 +0000
> +++ gcc/cse.c 2008-11-10 23:11:30.000000000 +0000
> @@ -3171,33 +3171,15 @@ fold_rtx (rtx x, rtx insn)
> {
> case RTX_UNARY:
> {
> - int is_const = 0;
> -
> /* We can't simplify extension ops unless we know the
> original mode. */
> if ((code == ZERO_EXTEND || code == SIGN_EXTEND)
> && mode_arg0 == VOIDmode)
> break;
>
> - /* If we had a CONST, strip it off and put it back later if we
> - fold. */
> - if (const_arg0 != 0 && GET_CODE (const_arg0) == CONST)
> - is_const = 1, const_arg0 = XEXP (const_arg0, 0);
> -
> new_rtx = simplify_unary_operation (code, mode,
> const_arg0 ? const_arg0 : folded_arg0,
> mode_arg0);
> - /* NEG of PLUS could be converted into MINUS, but that causes
> - expressions of the form
> - (CONST (MINUS (CONST_INT) (SYMBOL_REF)))
> - which many ports mistakenly treat as LEGITIMATE_CONSTANT_P.
> - FIXME: those ports should be fixed. */
> - if (new_rtx != 0 && is_const
> - && GET_CODE (new_rtx) == PLUS
> - && (GET_CODE (XEXP (new_rtx, 0)) == SYMBOL_REF
> - || GET_CODE (XEXP (new_rtx, 0)) == LABEL_REF)
> - && GET_CODE (XEXP (new_rtx, 1)) == CONST_INT)
> - new_rtx = gen_rtx_CONST (mode, new_rtx);
> }
> break;
>
>