public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/44462] New: Redundant looping pure functions whose return value is dead are not optimized out
@ 2010-06-08 7:32 hubicka at gcc dot gnu dot org
2010-06-08 8:49 ` [Bug tree-optimization/44462] " rguenth at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: hubicka at gcc dot gnu dot org @ 2010-06-08 7:32 UTC (permalink / raw)
To: gcc-bugs
For the following testcase:
__attribute__ ((noinline,noclone))
int
i_am_pure (int a)
{
if (a>10)
abort();
}
main()
{
int a = i_am_pure (5) + i_am_pure (5);
int b = i_am_pure (8) + i_am_pure (8);
return a;
}
We get only one call to i_am_pure optimized out:
main ()
{
int a;
int D.2721;
<bb 2>:
D.2721_1 = i_am_pure (5);
a_3 = D.2721_1 + D.2721_1;
i_am_pure (8);
i_am_pure (8);
return a_3;
}
This is becasue removal is done as part of PRE and we are not removing
function calls without return value.
Perhaps this can be improved to at least handle FRE quite easilly? In GCC we
now have about 1/4th of pure functions with WHOPR build and some results
especially in autogenerated files are unused and we end up with a lot of
redundant calls there.
Honza
--
Summary: Redundant looping pure functions whose return value is
dead are not optimized out
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hubicka at gcc dot gnu dot org
GCC host triplet: x86_64-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <bug-44462-4@http.gcc.gnu.org/bugzilla/>]
* [Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
[not found] <bug-44462-4@http.gcc.gnu.org/bugzilla/>
@ 2021-05-05 13:49 ` rguenth at gcc dot gnu.org
2021-05-10 9:45 ` rguenth at gcc dot gnu.org
1 sibling, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-05 13:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
So we now (GCC 8+ at least) get
<bb 2> :
_1 = i_am_pure (5);
a_8 = _1 * 2;
i_am_pure (8);
return a_8;
after early DCE. This is because we now do FRE before the first DCE which
4.5 didn't have (4.8 has that already).
So fixed for the testcase, not exactly in general though.
__attribute__ ((noinline,noclone))
int
i_am_pure (int a)
{
if (a>10)
__builtin_abort();
}
int main()
{
i_am_pure (8);
i_am_pure (8);
return 0;
}
is still not "CSE"d. The question is whether that happens in practice?
We do actually detect the "redundancy" during propagation but fail to
do anything in elimination - also because we don't properly track
"availability" here. As a first step one could handle the cases
where the call has the same VUSE, but that only helps for pure calls,
not const ones.
There's also the case of aggregate returns which makes the calls
receive vops:
struct S { int x; };
__attribute__ ((noinline,noclone))
struct S
i_am_pure (int a)
{
if (a>10)
__builtin_abort();
}
int main()
{
struct S x;
x = i_am_pure (8);
x = i_am_pure (8);
return 0;
}
which we do not optimize at all.
int main ()
{
struct S x;
<bb 2> [local count: 1073741824]:
x = i_am_pure (8);
x = i_am_pure (8);
x ={v} {CLOBBER};
return 0;
we could DSE the LHS of the calls it seems.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
[not found] <bug-44462-4@http.gcc.gnu.org/bugzilla/>
2021-05-05 13:49 ` rguenth at gcc dot gnu.org
@ 2021-05-10 9:45 ` rguenth at gcc dot gnu.org
1 sibling, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-10 9:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462
Bug 44462 depends on bug 100434, which changed state.
Bug 100434 Summary: DSE fails to DSE aggregate LHS.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100434
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-05-10 9:45 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-08 7:32 [Bug tree-optimization/44462] New: Redundant looping pure functions whose return value is dead are not optimized out hubicka at gcc dot gnu dot org
2010-06-08 8:49 ` [Bug tree-optimization/44462] " rguenth at gcc dot gnu dot org
2010-06-08 20:10 ` pinskia at gcc dot gnu dot org
2010-06-09 9:11 ` rguenther at suse dot de
2010-06-09 10:30 ` hubicka at ucw dot cz
[not found] <bug-44462-4@http.gcc.gnu.org/bugzilla/>
2021-05-05 13:49 ` rguenth at gcc dot gnu.org
2021-05-10 9:45 ` rguenth 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).