[Bug c/58808] New: Unnecessary MOV instruction generated
smeeze at catlover dot com
gcc-bugzilla@gcc.gnu.org
Sat Oct 19 19:11:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58808
Bug ID: 58808
Summary: Unnecessary MOV instruction generated
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: smeeze at catlover dot com
GCC sometimes generates an unnecessary MOV operation.
For example gcc -S test.c -masm=intel
on this code:
#include <stdio.h>
int main(){
int i = 2;
int b;
b = i + i + i;
printf("%d", b);
return 0;
}
Generates this
mov DWORD PTR [esp+28], 2
mov eax, DWORD PTR [esp+28]
add eax, eax
add eax, DWORD PTR [esp+28]
mov DWORD PTR [esp+24], eax
mov eax, DWORD PTR [esp+24] ;<-- Why?? The last instruction does not
affect EAX
mov DWORD PTR [esp+4], eax
mov DWORD PTR [esp], OFFSET FLAT:LC0
call _printf
More information about the Gcc-bugs
mailing list