User account creation filtered due to spam.

Bug 35361 - Missing IPA DCE and DSE
Summary: Missing IPA DCE and DSE
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: missed-optimization
Depends on:
Reported: 2008-02-25 05:23 UTC by davidxl
Modified: 2016-12-05 17:19 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2008-02-25 11:39:30


Note You need to log in before you can comment on or make changes to this bug.
Description davidxl 2008-02-25 05:23:51 UTC
// David Li

Gcc is solid in performing dead function elimination and dead variable elimination for statics. It handles cases when a dead variable is referenced (via initializer) by other dead variables pretty well. The missing opportunities noticed is that it fails to discover dead stores to static variables where are never used -- thus missing the dead variable elimination ...

Example 1:

static int s;
static int* p =&s;

int foo()
   p = 0;      // Dead, not eliminated

Example 2:

static int g = 10;
static int* gp = &g;

int foo()
  gp = 0;      // Dead store
  return g;    // should be const proped
Comment 1 Richard Biener 2008-02-25 11:39:30 UTC
It looks like this needs IPA DCE/DSE.
Comment 2 Jeffrey A. Law 2016-12-05 17:19:30 UTC
This was fixed a couple years ago:
Author: hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri May 16 17:49:06 2014 +0000

        * varpool.c (dump_varpool_node): Dump write-only flag.
        * lto-cgraph.c (lto_output_varpool_node, input_varpool_node): Stream
        write-only flag.
        * tree-cfg.c (execute_fixup_cfg): Remove statements setting write-only variables.
        * gcc.c-torture/execute/20101011-1.c: Update testcase.
        * gcc.dg/ira-shrinkwrap-prep-1.c: Update testcase.
        * gcc.dg/tree-ssa/writeonly.c: New testcase.
        * gcc.dg/tree-ssa/ssa-dse-6.c: Update testcase.
        * gcc.dg/tree-ssa/pr21559.c: Update testcase.
        * gcc.dg/debug/pr35154.c: Update testcase.
        * Update testcase.
        * ipa.c (process_references): New function.
        (set_readonly_bit): New function.
        (set_writeonly_bit): New function.
        (clear_addressable_bit): New function.
        (ipa_discover_readonly_nonaddressable_var): Mark write only variables; fix
        handling of aliases.
        * cgraph.h (struct varpool_node): Add writeonly flag.