public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <rdsandiford@googlemail.com>
To: gcc-patches@gcc.gnu.org
Subject: PR 37363 follow-on 1: avoid gen_rtx_CONST call in cse.c:fold_rtx
Date: Tue, 11 Nov 2008 04:14:00 -0000	[thread overview]
Message-ID: <87fxlzma7t.fsf@firetop.home> (raw)

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?

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;
 

             reply	other threads:[~2008-11-10 23:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-11  4:14 Richard Sandiford [this message]
2008-11-11 15:32 ` Richard Guenther

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fxlzma7t.fsf@firetop.home \
    --to=rdsandiford@googlemail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).