public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/6546: static const members optimization failure
@ 2002-05-03 10:07 jakub
0 siblings, 0 replies; 3+ messages in thread
From: jakub @ 2002-05-03 10:07 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, ncm, nobody
Synopsis: static const members optimization failure
State-Changed-From-To: open->analyzed
State-Changed-By: jakub
State-Changed-When: Fri May 3 10:07:14 2002
State-Changed-Why:
I think this basically waits for the AST optimizations.
In the meantime, something like:
--- gcc/expr.c.jj Fri May 3 18:58:54 2002
+++ gcc/expr.c Fri May 3 19:12:33 2002
@@ -6667,6 +6667,35 @@ expand_expr (exp, target, tmode, modifie
GEN_INT (trunc_int_for_mode (TREE_STRING_POINTER (string)
[TREE_INT_CST_LOW (index)], mode));
+ /* Try to optimize references to constant variables. */
+ if (optimize && TREE_READONLY (exp) && modifier != EXPAND_WRITE)
+ {
+ tree tem = exp1;
+ if (TREE_CODE (tem) == NOP_EXPR
+ && TREE_CODE (TREE_TYPE (tem)) == REFERENCE_TYPE
+ && TREE_TYPE (TREE_TYPE (tem)) == type
+ && TREE_READONLY (tem)
+ && TREE_CONSTANT (tem))
+ tem = TREE_OPERAND (tem, 0);
+ if (TREE_CODE (tem) == ADDR_EXPR
+ && TREE_CODE (TREE_TYPE (tem)) == POINTER_TYPE
+ && TREE_TYPE (TREE_TYPE (tem)) == type
+ && TREE_READONLY (tem)
+ && TREE_CONSTANT (tem))
+ {
+ tem = TREE_OPERAND (tem, 0);
+ if (TREE_CODE (tem) == VAR_DECL
+ && TREE_TYPE (tem) == type
+ && TREE_READONLY (tem)
+ && ! TREE_SIDE_EFFECTS (tem)
+ && DECL_INITIAL (tem)
+ && DECL_INITIAL (tem) != error_mark_node)
+ /* Record the actual variable decl below into MEM
+ attributes. */
+ exp = tem;
+ }
+ }
+
op0 = expand_expr (exp1, NULL_RTX, VOIDmode, EXPAND_SUM);
op0 = memory_address (mode, op0);
temp = gen_rtx_MEM (mode, op0);
and teaching CSE that for MEM/u which has MEM_EXPR set
to some VAR_DECL which is constant it could try to REG_EQUAL
it to that constant.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6546
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/6546: static const members optimization failure
@ 2002-06-27 15:56 mmitchel
0 siblings, 0 replies; 3+ messages in thread
From: mmitchel @ 2002-06-27 15:56 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, mmitchel, ncm
Synopsis: static const members optimization failure
State-Changed-From-To: analyzed->closed
State-Changed-By: mmitchel
State-Changed-When: Thu Jun 27 15:42:43 2002
State-Changed-Why:
Will not fix.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6546
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/6546: static const members optimization failure
@ 2002-06-27 15:26 mmitchel
0 siblings, 0 replies; 3+ messages in thread
From: mmitchel @ 2002-06-27 15:26 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, mmitchel, ncm, nobody
Synopsis: static const members optimization failure
Responsible-Changed-From-To: unassigned->mmitchel
Responsible-Changed-By: mmitchel
Responsible-Changed-When: Thu Jun 27 15:15:01 2002
Responsible-Changed-Why:
Analysis.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6546
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-06-27 22:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-03 10:07 c++/6546: static const members optimization failure jakub
2002-06-27 15:26 mmitchel
2002-06-27 15:56 mmitchel
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).