public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/16427] New: dead 0 memset not optimized away
@ 2004-07-08  1:25 ak at muc dot de
  2004-07-08  1:31 ` [Bug tree-optimization/16427] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 4+ messages in thread
From: ak at muc dot de @ 2004-07-08  1:25 UTC (permalink / raw)
  To: gcc-bugs

gcc version 3.5.0 20040704 (experimental)

void f(void)
{
        unsigned long x[16];
        memset(x, 0, sizeof(x));
}

generates 

f:
.LFB2:
        subq    $136, %rsp
.LCFI0:
        movl    $128, %edx
        xorl    %esi, %esi
        movq    %rsp, %rdi
        call    memset
        addq    $136, %rsp
        ret

but when the 0 is changed to 0xff or any other value != 0 you get

f:
.LFB2:
        subq    $16, %rsp
.LCFI0:
        addq    $16, %rsp
        ret

(which btw is also weird because it leaks 16 bytes, but that's a differen issue)

I would expect the 0 memset to be optimized away too.

Looking at the code builtin_memset calls clear_storage() for the 0 case
and store_by_pieces directly for any other values.
Clearly something clear_storage() does is giving the optimizer the fits.

-- 
           Summary: dead 0 memset not optimized away
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ak at muc dot de
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: x86_64-linux


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


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

* [Bug tree-optimization/16427] dead 0 memset not optimized away
  2004-07-08  1:25 [Bug rtl-optimization/16427] New: dead 0 memset not optimized away ak at muc dot de
@ 2004-07-08  1:31 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-08  1:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-08 01:31 -------
Oh that is not leaking.

The real issue is that the memset is not removed at the tree level.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
          Component|rtl-optimization            |tree-optimization
     Ever Confirmed|                            |1
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-08 01:31:55
               date|                            |


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


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

* [Bug tree-optimization/16427] dead 0 memset not optimized away
       [not found] <bug-16427-7834@http.gcc.gnu.org/bugzilla/>
  2008-06-22 21:55 ` pinskia at gcc dot gnu dot org
@ 2010-06-09 11:10 ` andi-gcc at firstfloor dot org
  1 sibling, 0 replies; 4+ messages in thread
From: andi-gcc at firstfloor dot org @ 2010-06-09 11:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from andi-gcc at firstfloor dot org  2010-06-09 11:09 -------
Jakub, for this example: how would you suggest to work around this warning?


-- 


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


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

* [Bug tree-optimization/16427] dead 0 memset not optimized away
       [not found] <bug-16427-7834@http.gcc.gnu.org/bugzilla/>
@ 2008-06-22 21:55 ` pinskia at gcc dot gnu dot org
  2010-06-09 11:10 ` andi-gcc at firstfloor dot org
  1 sibling, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-06-22 21:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-06-22 21:54 -------
Related to bug 36602.


-- 


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


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

end of thread, other threads:[~2010-06-09 11:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-08  1:25 [Bug rtl-optimization/16427] New: dead 0 memset not optimized away ak at muc dot de
2004-07-08  1:31 ` [Bug tree-optimization/16427] " pinskia at gcc dot gnu dot org
     [not found] <bug-16427-7834@http.gcc.gnu.org/bugzilla/>
2008-06-22 21:55 ` pinskia at gcc dot gnu dot org
2010-06-09 11:10 ` andi-gcc at firstfloor 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).