public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/32680] New: unneeded movsbl
@ 2007-07-08 20:26 romikb at mail dot ru
2007-07-08 20:29 ` [Bug middle-end/32680] " pinskia at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: romikb at mail dot ru @ 2007-07-08 20:26 UTC (permalink / raw)
To: gcc-bugs
Code compiled with -O2 -fomit-frame-pointer
char function1(){ return 10; }
char (*pfunc)() = function1;
char function2(){ return pfunc(); }
produce unneeded movsbl instruction:
_function2:
subl $12, %esp << unneeded
call *_pfunc
addl $12, %esp << unneeded
movsbl %al,%eax << unneeded
ret
eax register allready contains char and don't need to be converted.
Code for
long function1(){ return 10; }
long (*pfunc)() = function1;
lonf function2(){ return pfunc(); }
looks fine.
--
Summary: unneeded movsbl
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: romikb at mail dot ru
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32680
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/32680] unneeded movsbl
2007-07-08 20:26 [Bug c/32680] New: unneeded movsbl romikb at mail dot ru
@ 2007-07-08 20:29 ` pinskia at gcc dot gnu dot org
2007-07-09 5:44 ` romikb at mail dot ru
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-08 20:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-07-08 20:29 -------
> eax register allready contains char
not true but oh well, it is called promting for abi reasons.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |middle-end
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32680
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/32680] unneeded movsbl
2007-07-08 20:26 [Bug c/32680] New: unneeded movsbl romikb at mail dot ru
2007-07-08 20:29 ` [Bug middle-end/32680] " pinskia at gcc dot gnu dot org
@ 2007-07-09 5:44 ` romikb at mail dot ru
2007-07-09 9:50 ` rguenth at gcc dot gnu dot org
2007-07-09 9:54 ` [Bug middle-end/32680] fails to tailcall, useless stack adjustment rguenth at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: romikb at mail dot ru @ 2007-07-09 5:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from romikb at mail dot ru 2007-07-09 05:44 -------
(In reply to comment #1)
>> eax register allready contains char
> not true
Can you explain, please, why it is not true?
Direct call of "function1" not produce "unneed movsb", so why indirect call
produce it?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32680
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/32680] unneeded movsbl
2007-07-08 20:26 [Bug c/32680] New: unneeded movsbl romikb at mail dot ru
2007-07-08 20:29 ` [Bug middle-end/32680] " pinskia at gcc dot gnu dot org
2007-07-09 5:44 ` romikb at mail dot ru
@ 2007-07-09 9:50 ` rguenth at gcc dot gnu dot org
2007-07-09 9:54 ` [Bug middle-end/32680] fails to tailcall, useless stack adjustment rguenth at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-07-09 9:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2007-07-09 09:50 -------
It does:
function2:
.LFB3:
call function1
movsbl %al,%eax
ret
because this is what the C ABI specifies. Now, the stack adjustments are
indeed superfluous. And we fail to tailcall as well. The latter is
fixed with a patch of mine.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32680
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/32680] fails to tailcall, useless stack adjustment
2007-07-08 20:26 [Bug c/32680] New: unneeded movsbl romikb at mail dot ru
` (2 preceding siblings ...)
2007-07-09 9:50 ` rguenth at gcc dot gnu dot org
@ 2007-07-09 9:54 ` rguenth at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-07-09 9:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2007-07-09 09:54 -------
So I just applied it and now we get
function1:
.LFB2:
movl $10, %eax
ret
function2:
.LFB3:
movq pfunc(%rip), %r11
jmp *%r11
for the indirect call. Fixed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |RESOLVED
GCC target triplet| |x86_64-*-*, i?86-*-*
Keywords| |missed-optimization
Resolution| |FIXED
Summary|unneeded movsbl |fails to tailcall, useless
| |stack adjustment
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32680
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-07-09 9:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-08 20:26 [Bug c/32680] New: unneeded movsbl romikb at mail dot ru
2007-07-08 20:29 ` [Bug middle-end/32680] " pinskia at gcc dot gnu dot org
2007-07-09 5:44 ` romikb at mail dot ru
2007-07-09 9:50 ` rguenth at gcc dot gnu dot org
2007-07-09 9:54 ` [Bug middle-end/32680] fails to tailcall, useless stack adjustment rguenth at gcc dot gnu dot 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).