public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <rdsandiford@googlemail.com>
To: ramrad01@arm.com
Cc: Eric Botcazou <ebotcazou@adacore.com>,
	 gcc-patches@gcc.gnu.org,
	 Andrew Pinski <andrew.pinski@caviumnetworks.com>,
	 Uros Bizjak <ubizjak@gmail.com>,
	 Paul_Koning@dell.com,  kkojima@gcc.gnu.org,  aoliva@redhat.com,
	 dje.gcc@gmail.com,  uweigand@de.ibm.com,  walt@tilera.com
Subject: Re: RFA: Simplifying truncation and integer lowpart subregs
Date: Wed, 28 Nov 2012 21:45:00 -0000	[thread overview]
Message-ID: <87boehmmfi.fsf@talisman.default> (raw)
In-Reply-To: <CAJA7tRat+yxE2_-1iNtSX_iFsem8-mQxcnaY-aLmdawsYiPN8A@mail.gmail.com>	(Ramana Radhakrishnan's message of "Wed, 28 Nov 2012 02:27:11 +0000")

Ramana Radhakrishnan <ramana.gcc@googlemail.com> writes:
> On Sun, Oct 7, 2012 at 8:56 AM, Richard Sandiford
> <rdsandiford@googlemail.com> wrote:
>> Eric Botcazou <ebotcazou@adacore.com> writes:
>>>> I think modelling it as a TRUNCATE operation is correct for
>>>> !TRULY_NOOP_TRUNCATION (it's the bug that Andrew pointed out).
>>>> And we shouldn't generate an actual TRUNCATE rtx for
>>>> TRULY_NOOP_TRUNCATION (the thing about making
>>>> simplify_gen_unary (TRUNCATE, ...) no worse than simplify_gen_subreg
>>>> for those targets).  I suppose:
>>>>
>>>>       /* We can't handle truncation to a partial integer mode here
>>>>          because we don't know the real bitsize of the partial
>>>>          integer mode.  */
>>>>       if (GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
>>>>         break;
>>>>
>>>> might be a problem though; we should still allow a subreg to be
>>>> generated.  Is that what you were thinking of, or something else?
>>>
>>> I was thinking of the !TRULY_NOOP_TRUNCATION case, where the two operations
>>> aren't equivalent.  Generating TRUNCATE in simplify_subreg seems
>>> suspicious to
>>> me in this case but, if not doing it is the source of the bug, I guess I need
>>> to do some homework on this TRULY_NOOP_TRUNCATION stuff. :-)
>>>
>>> Maybe add a blurb to the head comment of simplify_truncation, explaining that
>>> it is valid to call the function both for TRUNCATEs and truncations to the
>>> lowpart, and why it is correct to generate new TRUNCATEs in the latter case.
>>
>> Yeah, in hindsight, the patch was definitely lacking commentary.
>> How about the patch below?  It also fixes the partial int case
>> and gets rid of the errant NOT hunk.  Tested in the same way as before.
>>
>> Richard
>>
>>
>> gcc/
>>         * machmode.h (GET_MODE_UNIT_PRECISION): New macro.
>>         * simplify-rtx.c (simplify_truncation): New function,
>>         extracted from simplify_subreg and (in small part) from
>>         simplify_unary_operation_1.
>>         (simplify_unary_operation_1) <TRUNCATE>: Use it.  Remove sign bit
>>         test for !TRULY_NOOP_TRUNCATION_MODES_P.
>>         (simplify_subreg): Use simplify_truncate for lowpart subregs
>>         where both the inner and outer modes are scalar integers.
>>         * config/mips/mips.c (mips_truncated_op_cost): New function.
>>         (mips_rtx_costs): Adjust test for BADDU.
>>         * config/mips/mips.md (*baddu_di<mode>): Push truncates to operands.
>
> This triggers PR55052 on ARM.I've attached the .i file and the dumps
> to the bug report.

Thanks.  I'd managed to drop a SCALAR_INT_MODE_P check when splitting
the ZERO_EXTEND handling into two.

This patch reinstates the check.  Tested on x86_64-linux-gnu and applied
as obvious.

Richard


gcc/
	PR rtl-optimization/55052
	* simplify-rtx.c (simplify_subreg): Restore SCALAR_INT_MODE_P check.

Index: gcc/simplify-rtx.c
===================================================================
--- gcc/simplify-rtx.c	2012-11-27 18:52:29.000000000 +0000
+++ gcc/simplify-rtx.c	2012-11-28 19:54:30.500525576 +0000
@@ -5875,7 +5875,7 @@ simplify_subreg (enum machine_mode outer
 
   /* A SUBREG resulting from a zero extension may fold to zero if
      it extracts higher bits that the ZERO_EXTEND's source bits.  */
-  if (GET_CODE (op) == ZERO_EXTEND)
+  if (GET_CODE (op) == ZERO_EXTEND && SCALAR_INT_MODE_P (innermode))
     {
       unsigned int bitpos = subreg_lsb_1 (outermode, innermode, byte);
       if (bitpos >= GET_MODE_PRECISION (GET_MODE (XEXP (op, 0)))

  reply	other threads:[~2012-11-28 21:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-25  8:04 [PATCH, rtl-optimization]: Fix PR54457, [x32] Fail to combine 64bit index + constant Uros Bizjak
2012-09-26 18:17 ` Richard Sandiford
2012-09-26 21:38   ` Eric Botcazou
2012-09-27 14:25     ` Uros Bizjak
2012-09-27 16:10       ` Richard Sandiford
2012-09-27 18:20         ` [PATCH v2, " Uros Bizjak
2012-09-27 18:35           ` Paul_Koning
2012-09-27 19:21             ` Uros Bizjak
2012-10-02  2:13               ` Andrew Pinski
2012-10-02 19:32                 ` Richard Sandiford
2012-10-06 10:22                   ` RFA: Simplifying truncation and integer lowpart subregs Richard Sandiford
2012-10-06 11:13                     ` Eric Botcazou
2012-10-06 12:39                       ` Richard Sandiford
2012-10-06 13:05                         ` Eric Botcazou
2012-10-07  8:56                           ` Richard Sandiford
2012-10-07 12:36                             ` Eric Botcazou
2012-11-28  2:27                             ` Ramana Radhakrishnan
2012-11-28 21:45                               ` Richard Sandiford [this message]
2012-09-27 20:33           ` [PATCH v2, rtl-optimization]: Fix PR54457, [x32] Fail to combine 64bit index + constant Jakub Jelinek
2012-09-27 22:37             ` Richard Sandiford
2012-09-28 15:39             ` Uros Bizjak
2012-09-30 11:40               ` Richard Sandiford
2012-10-03 11:07                 ` Paolo Bonzini

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=87boehmmfi.fsf@talisman.default \
    --to=rdsandiford@googlemail.com \
    --cc=Paul_Koning@dell.com \
    --cc=andrew.pinski@caviumnetworks.com \
    --cc=aoliva@redhat.com \
    --cc=dje.gcc@gmail.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kkojima@gcc.gnu.org \
    --cc=ramrad01@arm.com \
    --cc=ubizjak@gmail.com \
    --cc=uweigand@de.ibm.com \
    --cc=walt@tilera.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).