public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/25227]  New: code generation -- unnecessary spill of structure onto stack
@ 2005-12-02 18:13 bcrl at kvack dot org
  2005-12-02 18:26 ` [Bug middle-end/25227] struct whos size is > 64bit is always on the stack pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: bcrl at kvack dot org @ 2005-12-02 18:13 UTC (permalink / raw)
  To: gcc-bugs

The following test program spills res onto the stack when the value res.result,
which is already in a register, should be passed in a register to 
foo();

/* compile with: gcc -fomit-frame-pointer -S */
struct rw_res {
        long result;
        long pos_update;
};

struct file {
        long f_pos;
};

struct rw_res vfs_read(long pos);
long foo(long bar);

long sys_read(struct file *file)
{
        struct rw_res res;
        res = vfs_read(file->f_pos);
        return foo(res.result);
}


-- 
           Summary: code generation -- unnecessary spill of structure onto
                    stack
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bcrl at kvack dot org
 GCC build triplet: x86_64-unknown-linux
  GCC host triplet: x86_64-unknown-linux
GCC target triplet: x86_64-unknown-linux


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


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

* [Bug middle-end/25227] struct whos size is > 64bit is always on the stack
  2005-12-02 18:13 [Bug c/25227] New: code generation -- unnecessary spill of structure onto stack bcrl at kvack dot org
@ 2005-12-02 18:26 ` pinskia at gcc dot gnu dot org
  2005-12-02 18:30 ` pinskia at gcc dot gnu dot org
  2005-12-02 21:33 ` rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-02 18:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-12-02 18:26 -------
Confirmed,  Even though it is returned on the registers:
(call_insn 13 12 14 (set (parallel:BLK [
                (expr_list:REG_DEP_TRUE (reg:DI 0 ax)
                    (const_int 0 [0x0]))
                (expr_list:REG_DEP_TRUE (reg:DI 1 dx)
                    (const_int 8 [0x8]))
            ])
        (call (mem:QI (symbol_ref:DI ("vfs_read") [flags 0x41] <function_decl
0x2aaaab162e00 vfs_read>) [0 S1 A8])
            (const_int 0 [0x0]))) -1 (nil)
    (nil)
    (expr_list:REG_DEP_TRUE (use (reg:DI 5 di))
        (nil)))

we store the struct directly to the stack right after that:
(insn 16 15 17 (set (mem/s/c:DI (plus:DI (reg/f:DI 54 virtual-stack-vars)
                (const_int -32 [0xffffffffffffffe0])) [4 S8 A128])
        (reg:DI 61)) -1 (nil)
    (nil))

(insn 17 16 18 (set (mem/s/c:DI (plus:DI (reg/f:DI 54 virtual-stack-vars)
                (const_int -24 [0xffffffffffffffe8])) [4 S8 A64])
        (reg:DI 62)) -1 (nil)
    (nil))
and then we load it and store it again:
(insn 18 17 19 (set (reg:DI 63)
        (mem/s/c:DI (plus:DI (reg/f:DI 54 virtual-stack-vars)
                (const_int -32 [0xffffffffffffffe0])) [4 S8 A128])) -1 (nil)
    (nil))

(insn 19 18 20 (set (mem/s/c:DI (plus:DI (reg/f:DI 54 virtual-stack-vars)
                (const_int -16 [0xfffffffffffffff0])) [4 D.1642+0 S8 A64])
        (reg:DI 63)) -1 (nil)
    (nil))

(insn 20 19 21 (set (reg:DI 64)
        (mem/s/c:DI (plus:DI (reg/f:DI 54 virtual-stack-vars)
                (const_int -24 [0xffffffffffffffe8])) [4 S8 A64])) -1 (nil)
    (nil))

(insn 21 20 0 (set (mem/s/c:DI (plus:DI (reg/f:DI 54 virtual-stack-vars)
                (const_int -8 [0xfffffffffffffff8])) [4 D.1642+8 S8 A64])
        (reg:DI 64)) -1 (nil)
    (nil))


This is a mess.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
  GCC build triplet|x86_64-unknown-linux        |
   GCC host triplet|x86_64-unknown-linux        |
 GCC target triplet|x86_64-unknown-linux        |
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2005-12-02 18:26:38
               date|                            |
            Summary|code generation --          |struct whos size is > 64bit
                   |unnecessary spill of        |is always on the stack
                   |structure onto stack        |


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


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

* [Bug middle-end/25227] struct whos size is > 64bit is always on the stack
  2005-12-02 18:13 [Bug c/25227] New: code generation -- unnecessary spill of structure onto stack bcrl at kvack dot org
  2005-12-02 18:26 ` [Bug middle-end/25227] struct whos size is > 64bit is always on the stack pinskia at gcc dot gnu dot org
@ 2005-12-02 18:30 ` pinskia at gcc dot gnu dot org
  2005-12-02 21:33 ` rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-02 18:30 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


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


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

* [Bug middle-end/25227] struct whos size is > 64bit is always on the stack
  2005-12-02 18:13 [Bug c/25227] New: code generation -- unnecessary spill of structure onto stack bcrl at kvack dot org
  2005-12-02 18:26 ` [Bug middle-end/25227] struct whos size is > 64bit is always on the stack pinskia at gcc dot gnu dot org
  2005-12-02 18:30 ` pinskia at gcc dot gnu dot org
@ 2005-12-02 21:33 ` rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-12-02 21:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2005-12-02 21:33 -------
It looks like not a single RTL optimizer triggering.  It's bad from expand on,
and I guess having all mems around from the start is not making it easy.


-- 


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


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

end of thread, other threads:[~2005-12-02 21:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-02 18:13 [Bug c/25227] New: code generation -- unnecessary spill of structure onto stack bcrl at kvack dot org
2005-12-02 18:26 ` [Bug middle-end/25227] struct whos size is > 64bit is always on the stack pinskia at gcc dot gnu dot org
2005-12-02 18:30 ` pinskia at gcc dot gnu dot org
2005-12-02 21:33 ` rguenth 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).