public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/21046] New: move memory allocation out of a loop
@ 2005-04-15 12:42 tkoenig at gcc dot gnu dot org
2005-04-15 13:04 ` [Bug tree-optimization/21046] " giovannibajo at libero dot it
2005-04-15 13:37 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 7+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2005-04-15 12:42 UTC (permalink / raw)
To: gcc-bugs
Consider the following program fragment:
char *p;
int i;
for (i=0; i<10; i++)
{
p = malloc(20);
foo(p,i);
free(p);
}
}
The loop could be simplified into
p = malloc(20);
for (i=0; i<10; i++)
foo(p,i);
free(p);
This would reduce the overhead for memory allocation
considerably.
A more challenging case is to change
for (i=0; i<10; i++)
{
p = malloc(2*i+2);
foo(p,i);
free(p);
}
into
p = malloc(20);
for (i=0; i<10; i++)
foo(p,i);
free(p);
because the amount of memory allocated has an upper bound.
This is probably not a big win for straight C code. For languages
which generate temporary arrays at runtime, such as Fortran, it
could mean a significant reduction in memory management overhead.
--
Summary: move memory allocation out of a loop
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tkoenig at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21046
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/21046] move memory allocation out of a loop
2005-04-15 12:42 [Bug tree-optimization/21046] New: move memory allocation out of a loop tkoenig at gcc dot gnu dot org
@ 2005-04-15 13:04 ` giovannibajo at libero dot it
2005-04-15 13:37 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 7+ messages in thread
From: giovannibajo at libero dot it @ 2005-04-15 13:04 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2005-04-15 13:04 -------
I would think this is much more easily done in the frontend itself, which has a
higher level representation so that it is much easier to hoist and reuse
allocations.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21046
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/21046] move memory allocation out of a loop
2005-04-15 12:42 [Bug tree-optimization/21046] New: move memory allocation out of a loop tkoenig at gcc dot gnu dot org
2005-04-15 13:04 ` [Bug tree-optimization/21046] " giovannibajo at libero dot it
@ 2005-04-15 13:37 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-15 13:37 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-15 13:37 -------
(In reply to comment #1)
> I would think this is much more easily done in the frontend itself, which has a
> higher level representation so that it is much easier to hoist and reuse
> allocations.
Not really true anymore.
Confirmed, related to PR 19831.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |missed-optimization
Last reconfirmed|0000-00-00 00:00:00 |2005-04-15 13:37:14
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21046
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/21046] move memory allocation out of a loop
[not found] <bug-21046-4@http.gcc.gnu.org/bugzilla/>
2012-02-22 12:49 ` xiaoyuanbo at yeah dot net
2014-12-25 12:16 ` tkoenig at gcc dot gnu.org
@ 2020-11-11 9:22 ` tkoenig at gcc dot gnu.org
2 siblings, 0 replies; 7+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2020-11-11 9:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21046
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2014-12-25 00:00:00 |2020-11-11
--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Just thought to see if this has been fixed in the meantime;
it's not optimized with current trunk.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/21046] move memory allocation out of a loop
[not found] <bug-21046-4@http.gcc.gnu.org/bugzilla/>
2012-02-22 12:49 ` xiaoyuanbo at yeah dot net
@ 2014-12-25 12:16 ` tkoenig at gcc dot gnu.org
2020-11-11 9:22 ` tkoenig at gcc dot gnu.org
2 siblings, 0 replies; 7+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2014-12-25 12:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21046
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2010-04-29 09:33:08 |2014-12-25
CC| |tkoenig at gcc dot gnu.org
--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Any work being done on this?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/21046] move memory allocation out of a loop
[not found] <bug-21046-4@http.gcc.gnu.org/bugzilla/>
@ 2012-02-22 12:49 ` xiaoyuanbo at yeah dot net
2014-12-25 12:16 ` tkoenig at gcc dot gnu.org
2020-11-11 9:22 ` tkoenig at gcc dot gnu.org
2 siblings, 0 replies; 7+ messages in thread
From: xiaoyuanbo at yeah dot net @ 2012-02-22 12:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21046
xiaoyuanbo <xiaoyuanbo at yeah dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xiaoyuanbo at yeah dot net
--- Comment #4 from xiaoyuanbo <xiaoyuanbo at yeah dot net> 2012-02-22 12:42:13 UTC ---
you know stack one
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/21046] move memory allocation out of a loop
[not found] <bug-21046-10391@http.gcc.gnu.org/bugzilla/>
@ 2010-04-29 9:33 ` rguenth at gcc dot gnu dot org
0 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-29 9:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2010-04-29 09:33 -------
I am working on this one (well, the first testcase kind).
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
BugsThisDependsOn| |42958
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2006-03-05 22:09:11 |2010-04-29 09:33:08
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21046
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-11-11 9:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-15 12:42 [Bug tree-optimization/21046] New: move memory allocation out of a loop tkoenig at gcc dot gnu dot org
2005-04-15 13:04 ` [Bug tree-optimization/21046] " giovannibajo at libero dot it
2005-04-15 13:37 ` pinskia at gcc dot gnu dot org
[not found] <bug-21046-10391@http.gcc.gnu.org/bugzilla/>
2010-04-29 9:33 ` rguenth at gcc dot gnu dot org
[not found] <bug-21046-4@http.gcc.gnu.org/bugzilla/>
2012-02-22 12:49 ` xiaoyuanbo at yeah dot net
2014-12-25 12:16 ` tkoenig at gcc dot gnu.org
2020-11-11 9:22 ` tkoenig 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).