public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/54360] New: missed optimalization: unnecessary indirect call
@ 2012-08-23 14:52 neleai at seznam dot cz
2012-08-23 15:00 ` [Bug c/54360] " jakub at gcc dot gnu.org
2012-09-03 9:53 ` [Bug c/54360] missed optimization: " rguenth at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: neleai at seznam dot cz @ 2012-08-23 14:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54360
Bug #: 54360
Summary: missed optimalization: unnecessary indirect call
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: neleai@seznam.cz
Consider following program:
void bar(int *x);
int x(){
struct {
void (*b)(int *);
int a;
} foo;
foo.b=bar;
foo.b(&(foo.a));
foo.b(&(foo.a));
}
int y(){
void (*b)(int *);
int a;
b=bar;
b(&a);
b(&a);
}
In function x gcc eliminaties first indirect call but not second. In y both
calls are eliminated.
.file "s.c"
.text
.p2align 4,,15
.globl x
.type x, @function
x:
.LFB0:
.cfi_startproc
subq $24, %rsp
.cfi_def_cfa_offset 32
leaq 8(%rsp), %rdi
movq $bar, (%rsp)
call bar
leaq 8(%rsp), %rdi
call *(%rsp)
addq $24, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE0:
.size x, .-x
.p2align 4,,15
.globl y
.type y, @function
y:
.LFB1:
.cfi_startproc
subq $24, %rsp
.cfi_def_cfa_offset 32
leaq 12(%rsp), %rdi
call bar
leaq 12(%rsp), %rdi
call bar
addq $24, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE1:
.size y, .-y
.ident "GCC: (Debian 20120820-1) 4.8.0 20120820 (experimental) [trunk
revision 190537]"
.section .note.GNU-stack,"",@progbits
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/54360] missed optimalization: unnecessary indirect call
2012-08-23 14:52 [Bug c/54360] New: missed optimalization: unnecessary indirect call neleai at seznam dot cz
@ 2012-08-23 15:00 ` jakub at gcc dot gnu.org
2012-09-03 9:53 ` [Bug c/54360] missed optimization: " rguenth at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-08-23 15:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54360
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-08-23 15:00:25 UTC ---
That is because bar could do:
#include <stddef.h>
void baz (int *);
void bar (int *x)
{
struct S { void (*b) (int *); int a; } *p;
p = (struct S) ((char *) x - offsetof (struct S, a));
p->b = baz;
}
It can't do something similar in case of y.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/54360] missed optimization: unnecessary indirect call
2012-08-23 14:52 [Bug c/54360] New: missed optimalization: unnecessary indirect call neleai at seznam dot cz
2012-08-23 15:00 ` [Bug c/54360] " jakub at gcc dot gnu.org
@ 2012-09-03 9:53 ` rguenth at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-09-03 9:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54360
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-09-03 09:53:37 UTC ---
.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-09-03 9:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-23 14:52 [Bug c/54360] New: missed optimalization: unnecessary indirect call neleai at seznam dot cz
2012-08-23 15:00 ` [Bug c/54360] " jakub at gcc dot gnu.org
2012-09-03 9:53 ` [Bug c/54360] missed optimization: " rguenth at gcc dot gnu.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).