public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <tom@codesourcery.com>
To: Paolo Bonzini <bonzini@gnu.org>
Cc: Andrew Pinski <pinskia@gmail.com>,
	gcc-patches@gcc.gnu.org,  Bernd Schmidt <bernds@codesourcery.com>
Subject: Re: new sign/zero extension elimination pass
Date: Fri, 22 Oct 2010 09:05:00 -0000	[thread overview]
Message-ID: <4CC14AC5.8060405@codesourcery.com> (raw)
In-Reply-To: <4CC07005.9070601@gnu.org>

Paolo Bonzini wrote:
> On 10/21/2010 12:24 PM, Paolo Bonzini wrote:
>> On 10/18/2010 05:42 PM, Andrew Pinski wrote:
>>>>> For MIPS, compilation results in the following insns.
>>>>>
>>>>> (set (reg/v:SI 199)
>>>>> (sign_extend:SI (subreg:HI (reg:SI 200) 2)))
>>>>>
>>>>> ...
>>>>>
>>>>> (set (reg:QI 203)
>>>>> (subreg:QI (reg/v:SI 199) 3))
>>>>>
>>>>> These insns are the only def and the only use of reg 199, each 
>>>> located in a
>>>>> different bb.
>>> This sounds like a job for GCSE to do.
>> Actually, fwprop should _already_ do that if assuming simplify-rtx.c 
>> does the simplification of (subreg:QI (sign_extend:SI (subreg:HI (reg:SI 
>> 200) 2))) 3).
> 
> ... which this code should do in simplify_subreg:
> 
>   /* Optimize SUBREG truncations of zero and sign extended values.  */
>   if ((GET_CODE (op) == ZERO_EXTEND
>        || GET_CODE (op) == SIGN_EXTEND)
>       && GET_MODE_BITSIZE (outermode) < GET_MODE_BITSIZE (innermode))
>     {
>       unsigned int bitpos = subreg_lsb_1 (outermode, innermode, byte);
> 
>       /* If we're requesting the lowpart of a zero or sign extension,
>          there are three possibilities.  If the outermode is the same
>          as the origmode, we can omit both the extension and the subreg.
>          If the outermode is not larger than the origmode, we can apply
>          the truncation without the extension.  Finally, if the outermode
>          is larger than the origmode, but both are integer modes, we
>          can just extend to the appropriate mode.  */
>       if (bitpos == 0)
>         {
>           enum machine_mode origmode = GET_MODE (XEXP (op, 0));
>           if (outermode == origmode)
>             return XEXP (op, 0);
>           if (GET_MODE_BITSIZE (outermode) <= GET_MODE_BITSIZE (origmode))
>             return simplify_gen_subreg (outermode, XEXP (op, 0), origmode,
>                                         subreg_lowpart_offset (outermode,
>                                                                origmode));
>           if (SCALAR_INT_MODE_P (outermode))
>             return simplify_gen_unary (GET_CODE (op), outermode,
>                                        XEXP (op, 0), origmode);
>         }
> 
> However, the def of pseudo 200 is "complex enough" that fwprop will not want
> to propagate it unless it simplifies to a constant.
> 
> It should be enough to tell fwprop that such propagations are always fine
> if the destination pseudo has one use only.  In this case register pressure
> cannot increase.
> 
> Paolo

Paolo,

Thanks for the pointer to fwprop. I agree with you that for this example, it
would make sense to have this done in fwprop.

But, I still think we need the new pass. I don't see how fwprop would help in
the example mentioned in
http://gcc.gnu.org/ml/gcc-patches/2010-10/msg01796.html, where a superfluous
zero_extend:
...
(insn 10 9 11 2 ext13.c:5 (set (reg:SI 204 [ D.1987+-2 ])
        (zero_extend:SI (subreg:HI (reg:SI 213) 2))) 186 {*zero_extendhisi2}
(expr_list:REG_DEAD (reg:SI 213)
        (nil)))
...

is used by:
...
(insn 15 14 16 2 ext13.c:5 (set (reg:SI 217)
        (plus:SI (reg:SI 205 [ D.1988+-2 ])
            (reg:SI 204 [ D.1987+-2 ]))) 10 {*addsi3} (nil))

(insn 17 16 18 2 ext13.c:6 (set (reg:SI 218)
        (minus:SI (reg:SI 204 [ D.1987+-2 ])
            (reg:SI 205 [ D.1988+-2 ]))) 23 {subsi3} (expr_list:REG_DEAD (reg:SI
205 [ D.1988+-2 ])
        (expr_list:REG_DEAD (reg:SI 204 [ D.1987+-2 ])
            (nil))))
...

- Tom

  reply	other threads:[~2010-10-22  8:26 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-18 15:54 Tom de Vries
2010-10-18 16:03 ` Andrew Pinski
2010-10-18 16:59   ` Richard Guenther
2010-10-21 10:06     ` Tom de Vries
2010-10-21 10:44   ` Paolo Bonzini
2010-10-21 11:00     ` Paolo Bonzini
2010-10-21 17:21     ` Paolo Bonzini
2010-10-22  9:05       ` Tom de Vries [this message]
2010-10-22  9:24         ` Paolo Bonzini
2010-10-22  9:15 ` Eric Botcazou
2010-10-28 20:45   ` Tom de Vries
2010-10-29  2:11     ` Paolo Bonzini
2010-10-29  2:42       ` Paolo Bonzini
2010-10-31 19:30       ` Tom de Vries
2010-10-31 20:58         ` Joseph S. Myers
2010-10-31 21:11         ` Paolo Bonzini
2010-11-03 18:49           ` Eric Botcazou
2010-10-29  1:04   ` Paolo Bonzini
2010-10-29  1:33     ` Paolo Bonzini
2010-11-03 18:50     ` Eric Botcazou
2010-11-08 21:29     ` Tom de Vries
2010-11-08 22:11       ` Paolo Bonzini
2010-11-12  8:29         ` Tom de Vries
2010-11-13 10:41           ` Eric Botcazou
2012-07-11 10:31             ` Tom de Vries
2012-07-11 11:42               ` Jakub Jelinek
2012-07-11 13:01                 ` Tom de Vries
2012-07-12  1:52               ` Kenneth Zadeck
     [not found]               ` <4FFE2ADF.2060806@naturalbridge.com>
     [not found]                 ` <4FFE9346.2070806@mentor.com>
2012-07-12  9:21                   ` Tom de Vries
2012-07-12 12:05                     ` Kenneth Zadeck
2012-07-13  7:54                       ` Tom de Vries
2012-07-13 11:39                         ` Kenneth Zadeck
2012-07-13 12:58                           ` Tom de Vries
2012-07-17 15:17                         ` Kenneth Zadeck
2012-07-20 18:41                           ` Tom de Vries
2012-08-20 13:40               ` Tom de Vries
2010-10-28 20:55 ` Andrew Pinski
2010-10-28 21:00   ` Andrew Pinski
2010-10-28 21:12     ` Tom de Vries
2010-10-28 22:58       ` Andrew Pinski
2010-10-29 15:06         ` Tom de Vries
2010-10-29  0:34     ` Paolo Bonzini
2010-11-08 21:32 ` Andrew Pinski

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=4CC14AC5.8060405@codesourcery.com \
    --to=tom@codesourcery.com \
    --cc=bernds@codesourcery.com \
    --cc=bonzini@gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=pinskia@gmail.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).