This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/19789] New: tree optimizers do not know that constant global variables do not change
- From: "kazu at cs dot umass dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Feb 2005 13:21:49 -0000
- Subject: [Bug tree-optimization/19789] New: tree optimizers do not know that constant global variables do not change
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider:
void abort (void) __attribute__ ((noreturn));
union node
{
int dummy;
union node *ptr;
};
extern void bar (union node *tree);
extern const int global_constant;
void
foo (union node *p)
{
if (global_constant == 1)
abort ();
bar (p->ptr);
if (global_constant == 1)
abort ();
}
Note that if we get to the second "if", we know that global_constant != 1,
so we could remove the second "if".
The tree optimizers do not take this opportunity, but the RTL optimizers do.
--
Summary: tree optimizers do not know that constant global
variables do not change
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: missed-optimization, TREE
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=19789