public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: hjl.tools@gmail.com (H.J. Lu)
Cc: gcc-patches@gcc.gnu.org, bernds@codesourcery.com
Subject: Re: PATCH [10/n]: Prepare x32: PR rtl-optimization/49114: Reload failed to handle (set reg:X (plus:X (subreg:X (reg:Y) 0) (const
Date: Mon, 27 Jun 2011 19:21:00 -0000	[thread overview]
Message-ID: <201106271859.p5RIxBP1013069@d06av02.portsmouth.uk.ibm.com> (raw)
In-Reply-To: <BANLkTikaxbkQDW9ffgvkcFEroYgOVAKf6A@mail.gmail.com> from "H.J. Lu" at Jun 27, 2011 11:40:18 AM

H.J. Lu wrote:

> Reloads for insn # 588
> Reload 0: reload_in (DI) =3D (reg/v/f:DI 182 [ b ])
>         GENERAL_REGS, RELOAD_FOR_OPERAND_ADDRESS (opnum =3D 0)
>         reload_in_reg: (reg/v/f:DI 182 [ b ])
>         reload_reg_rtx: (reg:DI 1 dx)
> Reload 1: reload_in (DI) =3D (zero_extend:DI (plus:SI (subreg:SI (reg/v/f:D=
> I 182
> [ b ]) 0)
>                                                         (const_int 8 [0x8])=
> ))
>         GENERAL_REGS, RELOAD_FOR_OPERAND_ADDRESS (opnum =3D 0)
>         reload_in_reg: (zero_extend:DI (plus:SI (subreg:SI (reg/v/f:DI 182 =
> [ b
> ]) 0)
>                                                         (const_int 8 [0x8])=
> ))
>         reload_reg_rtx: (reg:DI 1 dx)
> Reload 2: reload_out (DF) =3D (mem:DF (zero_extend:DI (plus:SI (subreg:SI
> (reg/v/f:DI 182 [ b ]) 0)
>                                                             (const_int 8
> [0x8]))) [4 MEM[base: b_96(D), index: D.15020_278, step: 8, offset: 0B]+0 S8
> A64])
>         NO_REGS, RELOAD_FOR_OUTPUT (opnum =3D 0), optional
>         reload_out_reg: (mem:DF (zero_extend:DI (plus:SI (subreg:SI (reg/v/=
> f:DI
> 182 [ b ]) 0)
>                                                             (const_int 8
> [0x8]))) [4 MEM[base: b_96(D), index: D.15020_278, step: 8, offset: 0B]+0 S8
> A64])
> 
> leads to
> 

> (insn 1017 587 1020 34 (set (reg:DI 1 dx)
>         (mem/c:DI (plus:DI (reg/f:DI 7 sp)
>                 (const_int 112 [0x70])) [5 %sfp+-208 S8 A64])) spooles.c:29=
> 1 62
> {*movdi_internal_rex64}
>      (nil))

So this is the reload insn generated from reload 0.  So far so good.

> (insn 1020 1017 1022 34 (set (reg:SI 1 dx)
>         (const_int 8 [0x8])) spooles.c:291 64 {*movsi_internal}
>      (nil))
> 
> (insn 1022 1020 1023 34 (set (reg:SI 1 dx)
>         (reg:SI 1 dx)) spooles.c:291 64 {*movsi_internal}
>      (nil))
> 
> (insn 1023 1022 1024 34 (set (reg:SI 1 dx)
>         (plus:SI (reg:SI 1 dx)
>             (const_int 8 [0x8]))) spooles.c:291 248 {*lea_1_x32}
>      (expr_list:REG_EQUIV (plus:SI (subreg:SI (reg:DI 1 dx) 0)
>             (const_int 8 [0x8]))
>         (nil)))
> 
> (insn 1024 1023 588 34 (set (reg:DI 1 dx)
>         (zero_extend:DI (reg:SI 1 dx))) spooles.c:291 112
> {*zero_extendsidi2_rex64}
>      (expr_list:REG_EQUIV (zero_extend:DI (plus:SI (subreg:SI (reg:DI 1 dx)=
>  0)
>                 (const_int 8 [0x8])))
>         (nil)))

All these reload insns are generated from reload 1.

> (insn 588 1024 589 34 (set (mem:DF (reg:DI 1 dx) [4 MEM[base: b_96(D), inde=
> x:
> D.15020_278, step: 8, offset: 0B]+0 S8 A64])
>         (reg:DF 0 ax [orig:340 D.14980 ] [340])) spooles.c:291 106
> {*movdf_internal_rex64}
>      (nil))

This is the original reloaded insn.

> Reload 0 puts (reg/v/f:DI 182 [ b ]) in  (reg:DI 1 dx) for input.
> However, reload 2
> puts (reg/v/f:DI 182 [ b ]) in  (reg:DI 1 dx) for output.without checking w=
> hat
> reload 0 did.

Reload 2 is an optional reload which reload chose not to utilize, so this
is not really relevant here in any case.  There is no output reload.

The wrong code above originates from how reload 1 is handled:

gen_reload is called to load the ZERO_EXTEND into (reg:DI 1).  This triggers
the "unary predicate" path, which recurses into gen_reload to load the operand
of the ZERO_EXTEND (reg:SI 1), and subsequently generates insn 1024.

The recursive call loads (plus:SI (subreg:SI (reg:DI 1)) (const_int 8)) into
(reg:SI 1).  It attempts to do that in a single SET and fails (for some
reason).  It then attempts to load the constant (const_int 8) into the
destination register (insn 1020) [** which is broken **], and re-tries.
This still fails, so it falls through to the last attempt, which is to
instead copy the subreg to the destination (which results in insn 1022
as the subreg is optimized away at this point), followed by adding the
constant.

Note that the point marked with "[** which is broken **]" is the place
I pointed out in the previous mail.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com

  reply	other threads:[~2011-06-27 18:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-25 19:02 PATCH [10/n]: Prepare x32: PR rtl-optimization/49114: Reload failed to handle (set reg:X (plus:X (subreg:X (reg:Y) 0) (const_int))) H.J. Lu
2011-06-27 15:01 ` PATCH [10/n]: Prepare x32: PR rtl-optimization/49114: Reload failed to handle (set reg:X (plus:X (subreg:X (reg:Y) 0) (const_int Ulrich Weigand
2011-06-27 18:32   ` H.J. Lu
2011-06-27 18:51     ` PATCH [10/n]: Prepare x32: PR rtl-optimization/49114: Reload failed to handle (set reg:X (plus:X (subreg:X (reg:Y) 0) (const Ulrich Weigand
2011-06-27 18:56       ` H.J. Lu
2011-06-27 19:21         ` Ulrich Weigand [this message]
2011-06-27 21:20           ` H.J. Lu
2011-06-27 22:19             ` H.J. Lu
2011-06-27 22:26             ` Ulrich Weigand
2011-06-27 22:45               ` H.J. Lu
2011-06-27 22:53                 ` H.J. Lu
2011-06-27 23:36                   ` H.J. Lu
2011-06-28 15:05                     ` Ulrich Weigand
2011-06-28 15:08                       ` H.J. Lu
2011-06-28 15:19                         ` H.J. Lu
2011-06-28 15:45                           ` Ulrich Weigand
2011-06-28 16:18                             ` H.J. Lu
2011-06-28 22:16                               ` H.J. Lu
2011-06-29 13:00                                 ` Ulrich Weigand
2011-06-29 17:24                                   ` [commit] Fix -Werror build break (Re: PATCH [10/n]: Prepare x32: PR rtl-optimization/49114) Ulrich Weigand
2011-06-28 14:21                   ` PATCH [10/n]: Prepare x32: PR rtl-optimization/49114: Reload failed to handle (set reg:X (plus:X (subreg:X (reg:Y) 0) (const H.J. Lu

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=201106271859.p5RIxBP1013069@d06av02.portsmouth.uk.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=bernds@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@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).