[Bug middle-end/29215] Unnecessary use of stack space

joerg at netbsd dot org gcc-bugzilla@gcc.gnu.org
Mon Sep 25 16:57:00 GMT 2006



------- Comment #8 from joerg at netbsd dot org  2006-09-25 16:57 -------
> Second this is just a memcpy issue, short testcase:
> #include <string.h>
> 
> char buf[21];
> 
> int main(void)
> {
>         int a = 0xffffffff;
>         memcpy(buf, &a, 4);

This creates two movl, one for a and one to buf. When duplicating the memcpy
multiples times, it stays one for a and one for each memcpy.

Manually inline the original testcase shows the same behaviour.

I think the real problem is in this example a is written to the stack and not
optimised away. For the original test case the lazy stack cleanup would explain
the multiple assignments.


-- 

joerg at netbsd dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   GCC host triplet|                            |i386--netbsdelf
           Keywords|missed-optimization         |
      Known to fail|4.0.0 4.1.0 4.2.0           |
      Known to work|3.4.0                       |
            Summary|[4.0/4.1/4.2 Regression]    |Unnecessary use of stack
                   |memcpy is not fully         |space
                   |optimized any more          |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29215



More information about the Gcc-bugs mailing list