public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/27959]  New: s390x miscompilation due to clobbering literal pool base reg
@ 2006-06-08 13:33 jakub at gcc dot gnu dot org
  2006-06-08 13:54 ` [Bug target/27959] " jakub at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-06-08 13:33 UTC (permalink / raw)
  To: gcc-bugs

The testcase I'll attach is miscompiled on s390x with -m64 -O2 -mtune=z990
or -m64 -O2 -mtune=z9-109.
The test function needs a base reg (so %r13 is loaded early and during flow2
the %r13 references actually make it into the assembler).  But, during reload
a TImode pseudo is reloaded into TI %r12 (and therefore clobbers %r13 too)
and the testcase segfaults.


-- 
           Summary: s390x miscompilation due to clobbering literal pool base
                    reg
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org
GCC target triplet: s390x-linux


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


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

* [Bug target/27959] s390x miscompilation due to clobbering literal pool base reg
  2006-06-08 13:33 [Bug target/27959] New: s390x miscompilation due to clobbering literal pool base reg jakub at gcc dot gnu dot org
@ 2006-06-08 13:54 ` jakub at gcc dot gnu dot org
  2006-06-09  9:06 ` [Bug target/27959] [4.1 regression] " jakub at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-06-08 13:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jakub at gcc dot gnu dot org  2006-06-08 13:33 -------
Created an attachment (id=11638)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11638&action=view)
pr27959.c


-- 


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


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

* [Bug target/27959] [4.1 regression] s390x miscompilation due to clobbering literal pool base reg
  2006-06-08 13:33 [Bug target/27959] New: s390x miscompilation due to clobbering literal pool base reg jakub at gcc dot gnu dot org
  2006-06-08 13:54 ` [Bug target/27959] " jakub at gcc dot gnu dot org
@ 2006-06-09  9:06 ` jakub at gcc dot gnu dot org
  2006-06-09 12:40 ` krebbel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-06-09  9:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2006-06-09 08:56 -------
Works just fine in GCC 3.4.x (in that case with -O2 -mtune=z990 which fails
in 4.1.x as well) and works on the trunk too (but it is unclear whether that's
just because reload chooses different registers by accident or if the problem
has been really fixed).


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|s390x miscompilation due to |[4.1 regression] s390x
                   |clobbering literal pool base|miscompilation due to
                   |reg                         |clobbering literal pool base
                   |                            |reg


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


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

* [Bug target/27959] [4.1 regression] s390x miscompilation due to clobbering literal pool base reg
  2006-06-08 13:33 [Bug target/27959] New: s390x miscompilation due to clobbering literal pool base reg jakub at gcc dot gnu dot org
  2006-06-08 13:54 ` [Bug target/27959] " jakub at gcc dot gnu dot org
  2006-06-09  9:06 ` [Bug target/27959] [4.1 regression] " jakub at gcc dot gnu dot org
@ 2006-06-09 12:40 ` krebbel at gcc dot gnu dot org
  2006-06-14 10:28 ` [Bug middle-end/27959] " krebbel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: krebbel at gcc dot gnu dot org @ 2006-06-09 12:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from krebbel at gcc dot gnu dot org  2006-06-09 11:41 -------
On s390 we use a trick to make the literal pool base register
available "on demand". It is defined as eliminable register
which can be eliminated to itself with offset 0. When a reload round
finds a r13 (literal pool base) it asks the back end whether it can
be eliminated and the back end says no. So reload throws any pseudos
out of r13 and marks it as bad_spill_regs_global hence it won't be
used as a reload register.

In your example there is no literal pool reference when entering reload.
So the initial elimination step marks r13 as eliminable and therefore free
to be used in reloads and it actually is used in a reload. In the second 
round reload forces a constant into the literal pool what creates a 
literal pool reference. When update_eliminables is called r13 is marked 
as cant_eliminate and the respective bit in bad_spill_regs_global is set. 
So far so good.

Unfortunately reload seems to think that registers which were once good to
be used in reloads will be good for future reloads as well - thats my
impression at least. The bitmap used_spill_regs is not reset between the
reload rounds. used_spill_regs is used in finish_spills to recalculate the
spill_regs array which then contains r13 since it was used as reload reg in the
first round.

The following patch deletes all registers which are recognized by
update_eliminables as eliminable_previous but cant_eliminate now from the
used_spill_regs bitmap and fixes your testcase.

Since reload is always a bit dodgy and tends to be unpredictable I would be
interested in Ulrichs opinion about the patch. He knows much better whats
going on in reload. So Ulrich do think this makes sense?


Index: gcc/reload1.c
===================================================================
*** gcc/reload1.c.orig  2006-06-09 13:12:39.000000000 +0200
--- gcc/reload1.c       2006-06-09 13:14:54.000000000 +0200
*************** reload (rtx first, int global)
*** 987,992 ****
--- 987,994 ----
        HARD_REG_SET to_spill;
        CLEAR_HARD_REG_SET (to_spill);
        update_eliminables (&to_spill);
+       AND_COMPL_HARD_REG_SET(used_spill_regs, to_spill);
+ 
        for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
          if (TEST_HARD_REG_BIT (to_spill, i))
            {


-- 

krebbel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-06-09 11:41:57
               date|                            |


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


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

* [Bug middle-end/27959] [4.1 regression] s390x miscompilation due to clobbering literal pool base reg
  2006-06-08 13:33 [Bug target/27959] New: s390x miscompilation due to clobbering literal pool base reg jakub at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-06-09 12:40 ` krebbel at gcc dot gnu dot org
@ 2006-06-14 10:28 ` krebbel at gcc dot gnu dot org
  2006-06-14 14:23 ` krebbel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: krebbel at gcc dot gnu dot org @ 2006-06-14 10:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from krebbel at gcc dot gnu dot org  2006-06-14 09:24 -------
Subject: Bug 27959

Author: krebbel
Date: Wed Jun 14 09:24:44 2006
New Revision: 114636

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114636
Log:
2006-06-14  Andreas Krebbel  <krebbel1@de.ibm.com>

        PR middle-end/27959
        * reload1.c (reload): Remove registers returned by update_eliminables
        from used_spill_regs.

2006-06-14  Andreas Krebbel  <krebbel1@de.ibm.com>

        PR middle-end/27959
        * gcc.dg/pr27959.c: New testcase.


Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/pr27959.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/reload1.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/27959] [4.1 regression] s390x miscompilation due to clobbering literal pool base reg
  2006-06-08 13:33 [Bug target/27959] New: s390x miscompilation due to clobbering literal pool base reg jakub at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-06-14 10:28 ` [Bug middle-end/27959] " krebbel at gcc dot gnu dot org
@ 2006-06-14 14:23 ` krebbel at gcc dot gnu dot org
  2006-06-14 14:26 ` krebbel at gcc dot gnu dot org
  2007-01-10 19:36 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: krebbel at gcc dot gnu dot org @ 2006-06-14 14:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from krebbel at gcc dot gnu dot org  2006-06-14 14:20 -------
Subject: Bug 27959

Author: krebbel
Date: Wed Jun 14 14:19:54 2006
New Revision: 114640

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114640
Log:
2006-06-14  Andreas Krebbel  <krebbel1@de.ibm.com>

        PR middle-end/27959
        * reload1.c (reload): Remove registers returned by update_eliminables
        from used_spill_regs.

2006-06-14  Andreas Krebbel  <krebbel1@de.ibm.com>

        PR middle-end/27959
        * gcc.dg/pr27959.c: New testcase.


Added:
    trunk/gcc/testsuite/gcc.dg/pr27959.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/reload1.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/27959] [4.1 regression] s390x miscompilation due to clobbering literal pool base reg
  2006-06-08 13:33 [Bug target/27959] New: s390x miscompilation due to clobbering literal pool base reg jakub at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-06-14 14:23 ` krebbel at gcc dot gnu dot org
@ 2006-06-14 14:26 ` krebbel at gcc dot gnu dot org
  2007-01-10 19:36 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: krebbel at gcc dot gnu dot org @ 2006-06-14 14:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from krebbel at gcc dot gnu dot org  2006-06-14 14:22 -------
Patch committed to mainline and gcc 4.1 branch.


-- 

krebbel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug middle-end/27959] [4.1 regression] s390x miscompilation due to clobbering literal pool base reg
  2006-06-08 13:33 [Bug target/27959] New: s390x miscompilation due to clobbering literal pool base reg jakub at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-06-14 14:26 ` krebbel at gcc dot gnu dot org
@ 2007-01-10 19:36 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-01-10 19:36 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.1.2


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


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

end of thread, other threads:[~2007-01-10 19:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-08 13:33 [Bug target/27959] New: s390x miscompilation due to clobbering literal pool base reg jakub at gcc dot gnu dot org
2006-06-08 13:54 ` [Bug target/27959] " jakub at gcc dot gnu dot org
2006-06-09  9:06 ` [Bug target/27959] [4.1 regression] " jakub at gcc dot gnu dot org
2006-06-09 12:40 ` krebbel at gcc dot gnu dot org
2006-06-14 10:28 ` [Bug middle-end/27959] " krebbel at gcc dot gnu dot org
2006-06-14 14:23 ` krebbel at gcc dot gnu dot org
2006-06-14 14:26 ` krebbel at gcc dot gnu dot org
2007-01-10 19:36 ` pinskia 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).