This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/42958] Weird temporary array allocation
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Mar 2010 19:12:07 -0000
- Subject: [Bug fortran/42958] Weird temporary array allocation
- References: <bug-42958-10053@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #11 from rguenth at gcc dot gnu dot org 2010-03-27 19:12 -------
The middle-end ends up with the following optimized:
D.1776_95 = D.1775_94 - D.1591_90;
if (D.1776_95 <= 0)
goto <bb 34>;
else
goto <bb 33>;
<bb 33>:
D.1620_204 = __builtin_malloc (D.1795_11);
D.1796_281 = iy.dim[1].stride;
...
goto <bb 35>;
<bb 34>:
D.1620_135 = __builtin_malloc (1);
goto <bb 38>;
<bb 35>:
the loop code
<bb 38>:
Invalid sum of incoming frequencies 1062, should be 900
# D.1620_374 = PHI <D.1620_204(37), D.1620_135(34)>
if (D.1620_374 != 0B)
goto <bb 39>;
else
goto <bb 40>;
<bb 39>:
__builtin_free (D.1620_374);
so we are able to prove that if we end up allocating 1 byte only then
the loop isn't executed and we just free it (another missed middle-end
optimization, p = malloc(1); free (p); isn't optimized away).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42958