[Bug tree-optimization/54505] New: RFE: Inline function tables
avi at redhat dot com
gcc-bugzilla@gcc.gnu.org
Thu Sep 6 16:52:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54505
Bug #: 54505
Summary: RFE: Inline function tables
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: avi@redhat.com
It is common to see code such as
static const int (*ftable[])(struct context *) = {
[V1] = f1,
[V2] = f2,
...
};
...
{
ftable[nr](context);
}
However, this is less efficient than an equivalent switch () statement since
the calling convention must be observed. Some registers are clobbered, others
must be set to the arguments, and the functions must have a prolog and an
epilogue.
It is easy to recognize the pattern though and convert it into an equivalent
switch:
switch (nr) {
case V1:
f1(context);
break;
case V2:
f2(context);
break;
...
}
More information about the Gcc-bugs
mailing list