public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/36352] New: missed "inlining" of static untouched variable in linked once function
@ 2008-05-28 7:42 pinskia at gcc dot gnu dot org
2008-05-28 8:22 ` [Bug tree-optimization/36352] " pinskia at gcc dot gnu dot org
2008-05-28 9:01 ` rguenth at gcc dot gnu dot org
0 siblings, 2 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-05-28 7:42 UTC (permalink / raw)
To: gcc-bugs
While looking into PR 36297, I found this interesting missed optimization, it
only happens with linked once functions. Testcase:
template <int a> int f(void)
{
static int t = a;
return t;
}
int g(void)
{
return f<1>();
}
We should produce return 1 for both functions but currently we reference
f<1>::t .
--
Summary: missed "inlining" of static untouched variable in linked
once function
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36352
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/36352] missed "inlining" of static untouched variable in linked once function
2008-05-28 7:42 [Bug tree-optimization/36352] New: missed "inlining" of static untouched variable in linked once function pinskia at gcc dot gnu dot org
@ 2008-05-28 8:22 ` pinskia at gcc dot gnu dot org
2008-05-28 9:01 ` rguenth at gcc dot gnu dot org
1 sibling, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-05-28 8:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2008-05-28 08:21 -------
I think this is more of an issue of changing the variable to be readonly than
an "inlining" the variable issue as the following source works as expected:
template <int a> int f(int i)
{
static const int t = a;
static const int t1 = a;
return i?t:t1;
}
int g(void)
{
return f<1>(1);
}
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|missed "inlining" of static |missed "inlining" of static
|untouched variable in linked|untouched variable in linked
|once function |once function
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36352
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/36352] missed "inlining" of static untouched variable in linked once function
2008-05-28 7:42 [Bug tree-optimization/36352] New: missed "inlining" of static untouched variable in linked once function pinskia at gcc dot gnu dot org
2008-05-28 8:22 ` [Bug tree-optimization/36352] " pinskia at gcc dot gnu dot org
@ 2008-05-28 9:01 ` rguenth at gcc dot gnu dot org
1 sibling, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-05-28 9:01 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2008-05-28 09:00:31
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36352
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/36352] missed "inlining" of static untouched variable in linked once function
[not found] <bug-36352-4@http.gcc.gnu.org/bugzilla/>
2010-11-10 18:17 ` hubicka at gcc dot gnu.org
@ 2021-08-30 5:09 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-30 5:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36352
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is a testcase without templates:
inline int f(void)
{
static int t = 1;
return t;
}
int g(void)
{
return f();
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/36352] missed "inlining" of static untouched variable in linked once function
[not found] <bug-36352-4@http.gcc.gnu.org/bugzilla/>
@ 2010-11-10 18:17 ` hubicka at gcc dot gnu.org
2021-08-30 5:09 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 5+ messages in thread
From: hubicka at gcc dot gnu.org @ 2010-11-10 18:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36352
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hubicka at gcc dot gnu.org,
| |jakub at redhat dot com
--- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> 2010-11-10 18:17:15 UTC ---
We are not able to declare the var as readonly since we think that it might be
accessed by other module.
This is not true for local static of comdats as we know what that comdat does
with the function, but it is bit difficult to take advantage of this because we
see code after optimization and it is possible that we optimized away the
access in this unit but not in other.
Only way I see to handle this safely is to have ipa-reference done before early
optimization. I tried that some time ago and I know it broke thread local
storage because it does part of job at gimplification and part of job
afterwards leading to confusion when var becomes read only (it stays accessed
as thread local but it is not brought thread local by the later pass). This is
lost optimization.
Jakub, Richard, perhaps the rewrite made this possible? It would be nice
cleanup.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-30 5:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-28 7:42 [Bug tree-optimization/36352] New: missed "inlining" of static untouched variable in linked once function pinskia at gcc dot gnu dot org
2008-05-28 8:22 ` [Bug tree-optimization/36352] " pinskia at gcc dot gnu dot org
2008-05-28 9:01 ` rguenth at gcc dot gnu dot org
[not found] <bug-36352-4@http.gcc.gnu.org/bugzilla/>
2010-11-10 18:17 ` hubicka at gcc dot gnu.org
2021-08-30 5:09 ` pinskia at gcc dot gnu.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).