public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/14084] New: Reg allocator changes REG_EXPR
@ 2004-02-09 14:10 zlomek at gcc dot gnu dot org
  2004-02-09 14:12 ` [Bug middle-end/14084] " zlomek at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: zlomek at gcc dot gnu dot org @ 2004-02-09 14:10 UTC (permalink / raw)
  To: gcc-bugs

On ppc64 and probably all 64-bit big endian machines
global register allocator IMHO wrongly changes REG_EXPR of an "int" variable
stored in 64-bit when compiling attached testcase (even at -O0).

In the following example, repcount is a 32-bit "int" variable,
subreg:SI (reg:DI 118 [ repcount ]) 4)) is changed into
(reg:SI 0 0 [orig:118 repcount+4 ] [118]))

Note that repcount is only 4 bytes wide so offset 4 makes no sense.

lreg:

(insn 4 3 5 0 (set (reg:SI 119 [ repcount ])
        (subreg:SI (reg:DI 118 [ repcount ]) 4)) 303 {*movsi_internal1} (nil)
    (expr_list:REG_DEAD (reg:DI 118 [ repcount ])
        (nil))) 
                
greg:

(insn 4 3 5 0 (set (reg:SI 0 0 [orig:119 repcount ] [119])
        (reg:SI 0 0 [orig:118 repcount+4 ] [118])) 303 {*movsi_internal1} (nil)
    (nil))

This makes variable tracking think that there are two parts of that variable.

-- 
           Summary: Reg allocator changes REG_EXPR
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zlomek at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc64-unknown-linux
  GCC host triplet: powerpc64-unknown-linux
GCC target triplet: powerpc64-unknown-linux


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


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

* [Bug middle-end/14084] Reg allocator changes REG_EXPR
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
@ 2004-02-09 14:12 ` zlomek at gcc dot gnu dot org
  2004-02-09 16:40 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: zlomek at gcc dot gnu dot org @ 2004-02-09 14:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From zlomek at gcc dot gnu dot org  2004-02-09 14:12 -------
Created an attachment (id=5707)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5707&action=view)
Testcase for this PR


-- 


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


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

* [Bug middle-end/14084] Reg allocator changes REG_EXPR
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
  2004-02-09 14:12 ` [Bug middle-end/14084] " zlomek at gcc dot gnu dot org
@ 2004-02-09 16:40 ` pinskia at gcc dot gnu dot org
  2004-02-09 16:44 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-09 16:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-02-09 16:40 -------
A slightly older gcc and I do not see this (3.4.0 20031228), I am wondering if something changed 
between then and now which could have effected this.
Here is what I see:
lgrep:
(insn:HI 3 4 9 0 (set (reg/v:DI 118 [ repcount ])
        (reg:DI 3 [ repcount ])) 327 {*movdi_internal64} (nil)
    (expr_list:REG_DEAD (reg:DI 3 [ repcount ])
        (expr_list:REG_EQUIV (mem/f:DI (plus:DI (reg/f:DI ap)
                    (const_int 48 [0x30])) [3 repcount+0 S4 A64])
            (nil))))

(insn:HI 9 3 52 0 (set (reg/v:DI 119 [ rdcount ])
        (const_int 0 [0x0])) 327 {*movdi_internal64} (nil)
    (nil))

(insn:HI 52 9 53 0 (set (reg:CC 124)
        (compare:CC (subreg/s:SI (reg/v:DI 119 [ rdcount ]) 4)
            (subreg/s:SI (reg/v:DI 118 [ repcount ]) 4))) 412 {*cmpsi_internal1} (insn_list 9 (insn_list 3 (nil)))
    (expr_list:REG_EQUAL (compare:CC (const_int 0 [0x0])
            (subreg/s:SI (reg/v:DI 118 [ repcount ]) 4))
        (nil)))
grep:
(insn:HI 3 4 9 0 (set (reg/v:DI 30 [orig:118 repcount ] [118])
        (reg:DI 3 [ repcount ])) 327 {*movdi_internal64} (nil)
    (expr_list:REG_EQUIV (mem/f:DI (plus:DI (reg/f:DI ap)
                (const_int 48 [0x30])) [3 repcount+0 S4 A64])
        (nil)))

(insn:HI 9 3 52 0 (set (reg/v:DI 31 [orig:119 rdcount ] [119])
        (const_int 0 [0x0])) 327 {*movdi_internal64} (nil)
    (nil))

(insn:HI 52 9 53 0 (set (reg:CC 7 [124])
        (compare:CC (reg:SI 31 [orig:119 rdcount+4 ] [119])
            (reg:SI 30 [orig:118 repcount+4 ] [118]))) 412 {*cmpsi_internal1} (insn_list 9 (insn_list 3 (nil)))
    (expr_list:REG_EQUAL (compare:CC (const_int 0 [0x0])
            (subreg/s:SI (reg/v:DI 30 [orig:118 repcount ] [118]) 4))
        (nil)))
Which looks right.

-- 


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


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

* [Bug middle-end/14084] Reg allocator changes REG_EXPR
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
  2004-02-09 14:12 ` [Bug middle-end/14084] " zlomek at gcc dot gnu dot org
  2004-02-09 16:40 ` pinskia at gcc dot gnu dot org
@ 2004-02-09 16:44 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
  2004-02-09 16:49 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: zlomj9am at artax dot karlin dot mff dot cuni dot cz @ 2004-02-09 16:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From zlomj9am at artax dot karlin dot mff dot cuni dot cz  2004-02-09 16:44 -------
Subject: Re:  Reg allocator changes REG_EXPR

> A slightly older gcc and I do not see this (3.4.0 20031228), I am wondering if something changed 
> between then and now which could have effected this.
> Here is what I see:
> lgrep:
> 
> (insn:HI 52 9 53 0 (set (reg:CC 124)
>         (compare:CC (subreg/s:SI (reg/v:DI 119 [ rdcount ]) 4)
>             (subreg/s:SI (reg/v:DI 118 [ repcount ]) 4))) 412 {*cmpsi_internal1} (insn_list 9 (insn_list 3 (nil)))
>     (expr_list:REG_EQUAL (compare:CC (const_int 0 [0x0])
>             (subreg/s:SI (reg/v:DI 118 [ repcount ]) 4))
>         (nil)))
> grep:
>
> (insn:HI 52 9 53 0 (set (reg:CC 7 [124])
>         (compare:CC (reg:SI 31 [orig:119 rdcount+4 ] [119])
>             (reg:SI 30 [orig:118 repcount+4 ] [118]))) 412 {*cmpsi_internal1} (insn_list 9 (insn_list 3 (nil)))
>     (expr_list:REG_EQUAL (compare:CC (const_int 0 [0x0])
>             (subreg/s:SI (reg/v:DI 30 [orig:118 repcount ] [118]) 4))
>         (nil)))

I see the problem here:
(subreg/s:SI (reg/v:DI 118 [ repcount ]) 4)
is changed to
(reg:SI 30 [orig:118 repcount+4 ] [118])

Josef


-- 


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


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

* [Bug middle-end/14084] Reg allocator changes REG_EXPR
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-02-09 16:44 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
@ 2004-02-09 16:49 ` pinskia at gcc dot gnu dot org
  2004-02-09 17:06 ` zlomek at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-09 16:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-02-09 16:49 -------
Confirmed then, the variable tracking has to do a better job as this is correct because otherwise it will 
cause wrong code to change the reg allocator not to do this as values in the register are stored no 
matter what in the widess form, see:
/* Define this macro if it is advisable to hold scalars in registers
   in a wider mode than that declared by the program.  In such cases,
   the value is constrained to be within the bounds of the declared
   type, but kept valid in the wider mode.  The signedness of the
   extension may differ from that of the type.  */

#define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE)       \
  if (GET_MODE_CLASS (MODE) == MODE_INT         \
      && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
    (MODE) = TARGET_32BIT ? SImode : DImode;

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-02-09 16:49:51
               date|                            |


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


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

* [Bug middle-end/14084] Reg allocator changes REG_EXPR
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-02-09 16:49 ` pinskia at gcc dot gnu dot org
@ 2004-02-09 17:06 ` zlomek at gcc dot gnu dot org
  2004-02-14 19:46 ` [Bug middle-end/14084] Reg allocator incorrectly changes REG_OFFSET zlomek at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: zlomek at gcc dot gnu dot org @ 2004-02-09 17:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From zlomek at gcc dot gnu dot org  2004-02-09 17:06 -------
> I see the problem here:
> (subreg/s:SI (reg/v:DI 118 [ repcount ]) 4)
> is changed to
> (reg:SI 30 [orig:118 repcount+4 ] [118])

Maybe I did not make myself clear.
IMHO the problem is that REG_EXPR is changed, i.e. [ repcount ] is changed to [
repcount+4 ]. 
If it it correct to have there [repcount+4] (because of the SImode) then it is
not correct following insn because repcount also has SImode but "repcount" in
REG_EXPR:

(insn 4 3 5 0 (set (reg:SI 0 0 [orig:119 repcount ] [119])
        (reg:SI 0 0 [orig:118 repcount+4 ] [118])) 303 {*movsi_internal1} (nil)
    (nil))



-- 


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


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

* [Bug middle-end/14084] Reg allocator incorrectly changes REG_OFFSET
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-02-09 17:06 ` zlomek at gcc dot gnu dot org
@ 2004-02-14 19:46 ` zlomek at gcc dot gnu dot org
  2004-05-15 20:29 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: zlomek at gcc dot gnu dot org @ 2004-02-14 19:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From zlomek at gcc dot gnu dot org  2004-02-14 19:46 -------
Proposed patch
http://gcc.gnu.org/ml/gcc-patches/2004-02/msg01314.html

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Summary|Reg allocator changes       |Reg allocator incorrectly
                   |REG_EXPR                    |changes REG_OFFSET


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


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

* [Bug middle-end/14084] Reg allocator incorrectly changes REG_OFFSET
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-02-14 19:46 ` [Bug middle-end/14084] Reg allocator incorrectly changes REG_OFFSET zlomek at gcc dot gnu dot org
@ 2004-05-15 20:29 ` pinskia at gcc dot gnu dot org
  2004-05-20 19:55 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-15 20:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-15 04:28 -------
This causes wrong-debug IIRC.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|patch                       |wrong-debug
   Last reconfirmed|2004-02-09 16:49:51         |2004-05-15 04:28:28
               date|                            |


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


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

* [Bug middle-end/14084] Reg allocator incorrectly changes REG_OFFSET
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2004-05-15 20:29 ` pinskia at gcc dot gnu dot org
@ 2004-05-20 19:55 ` pinskia at gcc dot gnu dot org
  2004-05-27 17:41 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-20 19:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-19 20:22 -------
Newest patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-05/msg01221.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


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


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

* [Bug middle-end/14084] Reg allocator incorrectly changes REG_OFFSET
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2004-05-20 19:55 ` pinskia at gcc dot gnu dot org
@ 2004-05-27 17:41 ` cvs-commit at gcc dot gnu dot org
  2004-05-27 17:42 ` zlomek at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-05-27 17:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-05-27 04:28 -------
Subject: Bug 14084

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	zlomek@gcc.gnu.org	2004-05-27 04:28:12

Modified files:
	gcc            : ChangeLog emit-rtl.c 

Log message:
	PR middle-end/14084
	* emit-rtl.c (gen_rtx_REG_offset): Adjust the offset according
	to size of decl.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.3759&r2=2.3760
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/emit-rtl.c.diff?cvsroot=gcc&r1=1.391&r2=1.392



-- 


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


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

* [Bug middle-end/14084] Reg allocator incorrectly changes REG_OFFSET
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2004-05-27 17:41 ` cvs-commit at gcc dot gnu dot org
@ 2004-05-27 17:42 ` zlomek at gcc dot gnu dot org
  2004-05-27 17:42 ` pinskia at gcc dot gnu dot org
  2004-06-05 14:11 ` cvs-commit at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: zlomek at gcc dot gnu dot org @ 2004-05-27 17:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From zlomek at gcc dot gnu dot org  2004-05-27 04:31 -------
Fixed.

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


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


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

* [Bug middle-end/14084] Reg allocator incorrectly changes REG_OFFSET
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2004-05-27 17:42 ` zlomek at gcc dot gnu dot org
@ 2004-05-27 17:42 ` pinskia at gcc dot gnu dot org
  2004-06-05 14:11 ` cvs-commit at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-27 17:42 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |3.5.0


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


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

* [Bug middle-end/14084] Reg allocator incorrectly changes REG_OFFSET
  2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2004-05-27 17:42 ` pinskia at gcc dot gnu dot org
@ 2004-06-05 14:11 ` cvs-commit at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-06-05 14:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-06-05 14:10 -------
Subject: Bug 14084

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	hammer-3_3-branch
Changes by:	zlomek@gcc.gnu.org	2004-06-05 14:10:54

Modified files:
	gcc            : ChangeLog.hammer emit-rtl.c 

Log message:
	Backport from mainline:
	2004-05-27  Josef Zlomek  <zlomekj@suse.cz>
	
	PR middle-end/14084
	* emit-rtl.c (gen_rtx_REG_offset): Adjust the offset according
	to size of decl.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.hammer.diff?cvsroot=gcc&only_with_tag=hammer-3_3-branch&r1=1.1.2.406&r2=1.1.2.407
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/emit-rtl.c.diff?cvsroot=gcc&only_with_tag=hammer-3_3-branch&r1=1.302.2.12&r2=1.302.2.13



-- 


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


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

end of thread, other threads:[~2004-06-05 14:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-09 14:10 [Bug middle-end/14084] New: Reg allocator changes REG_EXPR zlomek at gcc dot gnu dot org
2004-02-09 14:12 ` [Bug middle-end/14084] " zlomek at gcc dot gnu dot org
2004-02-09 16:40 ` pinskia at gcc dot gnu dot org
2004-02-09 16:44 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
2004-02-09 16:49 ` pinskia at gcc dot gnu dot org
2004-02-09 17:06 ` zlomek at gcc dot gnu dot org
2004-02-14 19:46 ` [Bug middle-end/14084] Reg allocator incorrectly changes REG_OFFSET zlomek at gcc dot gnu dot org
2004-05-15 20:29 ` pinskia at gcc dot gnu dot org
2004-05-20 19:55 ` pinskia at gcc dot gnu dot org
2004-05-27 17:41 ` cvs-commit at gcc dot gnu dot org
2004-05-27 17:42 ` zlomek at gcc dot gnu dot org
2004-05-27 17:42 ` pinskia at gcc dot gnu dot org
2004-06-05 14:11 ` cvs-commit 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).