public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/21223] New: Output register variable is reloaded into the wrong register for asm
@ 2005-04-25 20:49 drow at gcc dot gnu dot org
  2005-04-25 20:54 ` [Bug rtl-optimization/21223] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: drow at gcc dot gnu dot org @ 2005-04-25 20:49 UTC (permalink / raw)
  To: gcc-bugs

Compile this test with an ARM-targeted compiler.  Using -O2, it works out OK;
but for -O0 or -O1 it doesn't.  I originally encountered the bug in -O2 compiled
code, but a more complex testcase is probably necessary for that.

int bar(int *mem)
{
  return ({ register int a_oldval asm ("r0");
            register int a_tmp asm ("r3");
            int a_oldval2 = 3;
            __asm__ __volatile__ ("# Should be r0 - %0\n\t"
                                  "# Should be r3 - %1"
                                  : "=&r" (a_oldval), "=&r" (a_tmp)
                                  : "r" (a_oldval2));
            a_tmp; });
}

Everything is OK up until reload.  Then this happens:

Spilling for insn 19.
Using reg 2 for reload 0
Spilling for insn 19.
Using reg 2 for reload 0

Reloads for insn # 19
Reload 0: reload_out (SI) = (reg/v:SI 3 r3 [ a_tmp ])
        GENERAL_REGS, RELOAD_OTHER (opnum = 1)
        reload_out_reg: (reg/v:SI 3 r3 [ a_tmp ])
        reload_reg_rtx: (reg:SI 2 r2)

and the set of a_tmp is replaced by a set of r2.  I can't figure out why
the reload was created.

-- 
           Summary: Output register variable is reloaded into the wrong
                    register for asm
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drow at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: arm-none-linux-gnueabi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21223


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/21223] Output register variable is reloaded into the wrong register for asm
  2005-04-25 20:49 [Bug rtl-optimization/21223] New: Output register variable is reloaded into the wrong register for asm drow at gcc dot gnu dot org
@ 2005-04-25 20:54 ` pinskia at gcc dot gnu dot org
  2005-04-25 21:08 ` drow at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-25 20:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-25 20:54 -------
Confirmed, also on powerpc-darwin. Weird.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
 GCC target triplet|arm-none-linux-gnueabi      |arm-none-linux-gnueabi,
                   |                            |powerpc-darwin
           Keywords|                            |wrong-code
      Known to fail|                            |3.3.3 4.1.0
   Last reconfirmed|0000-00-00 00:00:00         |2005-04-25 20:54:01
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21223


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/21223] Output register variable is reloaded into the wrong register for asm
  2005-04-25 20:49 [Bug rtl-optimization/21223] New: Output register variable is reloaded into the wrong register for asm drow at gcc dot gnu dot org
  2005-04-25 20:54 ` [Bug rtl-optimization/21223] " pinskia at gcc dot gnu dot org
@ 2005-04-25 21:08 ` drow at gcc dot gnu dot org
  2005-04-25 21:10 ` [Bug middle-end/21223] " pinskia at gcc dot gnu dot org
  2005-04-25 21:13 ` drow at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: drow at gcc dot gnu dot org @ 2005-04-25 21:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From drow at gcc dot gnu dot org  2005-04-25 21:07 -------
The reload was created because the earlyclobber operand conflicts with
a_oldval2, which is placed in r3 by local-alloc.  I think I see why...

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21223


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/21223] Output register variable is reloaded into the wrong register for asm
  2005-04-25 20:49 [Bug rtl-optimization/21223] New: Output register variable is reloaded into the wrong register for asm drow at gcc dot gnu dot org
  2005-04-25 20:54 ` [Bug rtl-optimization/21223] " pinskia at gcc dot gnu dot org
  2005-04-25 21:08 ` drow at gcc dot gnu dot org
@ 2005-04-25 21:10 ` pinskia at gcc dot gnu dot org
  2005-04-25 21:13 ` drow at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-25 21:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-25 21:09 -------
And here is an x86 testcase:
int bar(int *mem)
{
  return ({ register int a_oldval asm ("eax");
            register int a_tmp asm ("ebx");
            int a_oldval2 = 3;
            __asm__ __volatile__ ("# Should be eax - %0\n\t"
                                  "# Should be ebx - %1\n\t"
                                  "# unknown - %2"
                                  : "=&r" (a_oldval), "=&r" (a_tmp)
                                  : "r" (a_oldval2));
            a_tmp; });
}

Which shows this fails at -O2 and above too.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|rtl-optimization            |middle-end
 GCC target triplet|arm-none-linux-gnueabi,     |
                   |powerpc-darwin              |
      Known to fail|3.3.3 4.1.0                 |3.3.3 4.1.0 2.95.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21223


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/21223] Output register variable is reloaded into the wrong register for asm
  2005-04-25 20:49 [Bug rtl-optimization/21223] New: Output register variable is reloaded into the wrong register for asm drow at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-04-25 21:10 ` [Bug middle-end/21223] " pinskia at gcc dot gnu dot org
@ 2005-04-25 21:13 ` drow at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: drow at gcc dot gnu dot org @ 2005-04-25 21:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From drow at gcc dot gnu dot org  2005-04-25 21:12 -------
The problem is in reg_is_set or its caller.

Because the output is an earlyclobber operand, it needs to be marked as born
before the insn, to conflict with its inputs.  I do not see an obvious way to
get from note_stores to the recog alternative.

I reproduced this bug in 3.4.3 (csl-arm-branch) also.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21223


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-04-25 21:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-25 20:49 [Bug rtl-optimization/21223] New: Output register variable is reloaded into the wrong register for asm drow at gcc dot gnu dot org
2005-04-25 20:54 ` [Bug rtl-optimization/21223] " pinskia at gcc dot gnu dot org
2005-04-25 21:08 ` drow at gcc dot gnu dot org
2005-04-25 21:10 ` [Bug middle-end/21223] " pinskia at gcc dot gnu dot org
2005-04-25 21:13 ` drow at gcc dot gnu dot org

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).