public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/17046] New: An unused array is not optimized away.
@ 2004-08-16  6:56 kazu at cs dot umass dot edu
  2004-08-16  7:02 ` [Bug tree-optimization/17046] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-08-16  6:56 UTC (permalink / raw)
  To: gcc-bugs

Consider:

static const int banana[] = { 0, 1, 2, 3 };

int
foo (void)
{
  int a = banana[2];
  return a * 0;
}

./cc1 -O2 -fomit-frame-pointer generates:

        .file   "test.c"
        .section        .rodata
        .align 4
        .type   banana, @object
        .size   banana, 16
banana:
        .long   0
        .long   1
        .long   2
        .long   3
        .text
        .p2align 2,,3
.globl foo
        .type   foo, @function
foo:
        xorl    %eax, %eax
        ret
        .size   foo, .-foo
        .ident  "GCC: (GNU) 3.5.0 20040816 (experimental)"
        .section        .note.GNU-stack,"",@progbits

Note that array "banana" is not optimized away.

-- 
           Summary: An unused array is not optimized away.
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug tree-optimization/17046] An unused array is not optimized away.
  2004-08-16  6:56 [Bug tree-optimization/17046] New: An unused array is not optimized away kazu at cs dot umass dot edu
@ 2004-08-16  7:02 ` pinskia at gcc dot gnu dot org
  2004-08-16  7:31 ` kazu at cs dot umass dot edu
  2005-05-04  2:16 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-16  7:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-16 07:02 -------
Confirmed, I think this is a case where we are marking the static variable as referenced too early.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-08-16 07:02:20
               date|                            |


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


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

* [Bug tree-optimization/17046] An unused array is not optimized away.
  2004-08-16  6:56 [Bug tree-optimization/17046] New: An unused array is not optimized away kazu at cs dot umass dot edu
  2004-08-16  7:02 ` [Bug tree-optimization/17046] " pinskia at gcc dot gnu dot org
@ 2004-08-16  7:31 ` kazu at cs dot umass dot edu
  2005-05-04  2:16 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-08-16  7:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-08-16 07:31 -------
Yes.  In fact, the following piece of code does *not*
generate the array in the assembly output.

static const int banana[] = { 0, 1, 2, 3 };

int
foo (void)
{
  return banana[2] * 0;
}

Note that the fix for this bug is important so that we can cleanly
fix PR 14841 because uses of "static const arrays" may disappear
during tree optimization.


-- 


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


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

* [Bug tree-optimization/17046] An unused array is not optimized away.
  2004-08-16  6:56 [Bug tree-optimization/17046] New: An unused array is not optimized away kazu at cs dot umass dot edu
  2004-08-16  7:02 ` [Bug tree-optimization/17046] " pinskia at gcc dot gnu dot org
  2004-08-16  7:31 ` kazu at cs dot umass dot edu
@ 2005-05-04  2:16 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-04  2:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-04 02:16 -------
Fixed for 4.1.0, most likely by the patches by Jan Honza.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


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


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

end of thread, other threads:[~2005-05-04  2:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-16  6:56 [Bug tree-optimization/17046] New: An unused array is not optimized away kazu at cs dot umass dot edu
2004-08-16  7:02 ` [Bug tree-optimization/17046] " pinskia at gcc dot gnu dot org
2004-08-16  7:31 ` kazu at cs dot umass dot edu
2005-05-04  2:16 ` 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).