public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Adam Nemet <anemet@caviumnetworks.com>
To: Jeff Law <law@redhat.com>
Cc: Ian Lance Taylor <iant@google.com>,     gcc@gcc.gnu.org
Subject: Re: Rationale for an old TRUNCATE patch
Date: Wed, 17 Jun 2009 06:17:00 -0000	[thread overview]
Message-ID: <19000.35070.420049.574430@ropi.home> (raw)
In-Reply-To: <4A385135.3070308@redhat.com>

Jeff Law writes:
> Ian Lance Taylor wrote:
> > Adam Nemet <anemet@caviumnetworks.com> writes:
> >
> >   
> >> I am trying to understand the checkin by Jeff Law from about 11 years ago:
> >>
> >>    r19204 | law | 1998-04-14 01:04:21 -0700 (Tue, 14 Apr 1998) | 4 lines
> >>    
> >>    
> >>            * combine.c (simplify_rtx, case TRUNCATE): Respect value of
> >>            TRULY_NOOP_TRUNCATION.
> >>    
> >>    
> >>    Index: combine.c
> >>    ===================================================================
> >>    --- combine.c	(revision 19018)
> >>    +++ combine.c	(revision 19204)
> >>    @@ -3736,7 +3736,9 @@ simplify_rtx (x, op0_mode, last, in_dest
> >>           if (GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
> >>     	break;
> >>     
> >>    -      if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
> >>    +      if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
> >>    +	  && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
> >>    +				    GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0)))))
> >>     	SUBST (XEXP (x, 0),
> >>     	       force_to_mode (XEXP (x, 0), GET_MODE (XEXP (x, 0)),
> >>     			      GET_MODE_MASK (mode), NULL_RTX, 0));
> >>
> >> This optimization simplifies the input to a truncate by only computing bits
> >> that won't be eliminated by the truncation.  Normally these are the bits in
> >> the output mode mask.  Note that the optimization does not change the truncate
> >> into a low-part subreg, which would pretty automatically warrant the
> >> TRULY_NOOP_TRUNCATION check.
> >>     
> >
> > I agree that this patch looks wrong in todays compiler.  There should be
> > no need to call TRULY_NOOP_TRUNCATION if you are in a TRUNCATE anyhow.
> >   
> Based on reviewing my old notes, we do have to ensure that combine 
> doesn't replace a TRUNCATE with a SUBREG as that can result in having a 
> 32bit value that isn't sign-extended, which clearly causes MIPS64 ports 
> grief.

Thanks for the long information in your other reply.

As I said in the original email, we are not turning a TRUNCATE into a SUBREG
in this transformation.  We're just simplifying the input expression to
truncate with the knowledge that only the truncated mode bits are relevant
from the input.  At the end we are still left with a truncate expression but
possibly with a simpler operand.

Adam

  reply	other threads:[~2009-06-17  6:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-16  7:12 Adam Nemet
2009-06-16 14:35 ` Ian Lance Taylor
2009-06-16 22:45   ` Adam Nemet
2009-06-17  0:28     ` Ian Lance Taylor
2009-06-17  6:42       ` Adam Nemet
2009-06-17 14:24         ` Ian Lance Taylor
2009-06-17 15:26           ` Adam Nemet
2009-06-17 15:54             ` Ian Lance Taylor
2009-06-17  2:12   ` Jeff Law
2009-06-17  6:17     ` Adam Nemet [this message]
2009-06-17 14:52       ` Jeff Law
2009-06-17  2:10 ` Jeff Law

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=19000.35070.420049.574430@ropi.home \
    --to=anemet@caviumnetworks.com \
    --cc=gcc@gcc.gnu.org \
    --cc=iant@google.com \
    --cc=law@redhat.com \
    /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).