Bug 41749 - non-needed instructions are not removed (not optimized)
Summary: non-needed instructions are not removed (not optimized)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.3
: P3 minor
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-19 07:10 UTC by Коренберг Марк
Modified: 2009-10-20 05:00 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.0
Known to fail: 4.3.4 4.3.3
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Коренберг Марк 2009-10-19 07:10:20 UTC
int main (void) {    return 1; }

Ubuntu Jaunty.

gcc --save-temps -fno-stack-protector -fomit-frame-pointer -Os ./cpuid.c

generates thgis:
--------------
main:
	leal	4(%esp), %ecx
	andl	$-16, %esp
	pushl	-4(%ecx)
	movl	$1, %eax
	pushl	%ecx
	popl	%ecx
	leal	-4(%ecx), %esp
	ret
--------------------------
why i get this:
	pushl	%ecx
	popl	%ecx
and other non-needed instructions (for another example)
pushl	%ebp
andl	$1, %eax
movl	%esp, %ebp
pushl	%ecx
popl	%ecx
popl	%ebp

These instructions are not optimized not in -O3, nor in -Os
Comment 1 Коренберг Марк 2009-10-19 07:14:32 UTC
gcc322 generates this:
(gcc -Os -fomit-frame-pointer qwe.c --save-temps)

main:                                                              
        movl    $1, %eax                                           
        ret                                                        

WTF?
Comment 2 Richard Biener 2009-10-19 10:58:22 UTC
It aligns the incoming stack.  Fixed in 4.4/4.5.