| Submitter | Michael Matz |
|---|---|
| Date | Feb. 19, 2013, 3:10 p.m. |
| Message ID | <alpine.LNX.2.00.1302191607550.4259@wotan.suse.de> |
| Download | mbox | patch |
| Permalink | /patch/221713/ |
| State | New |
| Headers | show |
Comments
On Tue, Feb 19, 2013 at 4:10 PM, Michael Matz <matz@suse.de> wrote: > Hi, > > from IRC: > "[15:45:21] <richi> ick - lookup_constraint for multi-letter constraints > is quite expensive ... strncmp is not expanded inline for some reason" > > Instead of fiddling with strncmp inlining, simply generate better code > from the start for two character constraints: > > switch (str[0]) { > case 'Y': > switch (str[1]) > { > case 'i': > return CONSTRAINT_Yi; > case 'm': > return CONSTRAINT_Ym; > > ... Bootstrapped and tested on ... ? I suppose this is ok, even ontop of my recent improvement (which we noticed can be improved further by using memcmp instead of strncmp). We seem to have at most seven-letter constraints at the moment (rx port - they seem to use descriptive constraint names like "NEGint4" and "Symbol" with only 10 constraints in total ...). I wonder where the cut-off is for expanding the whole comparison to nested switch statements ... or even expand the 2nd level to a switch on properly masked short / int / long compares. Richard. > > Ciao, > Michael. > -- > * genpreds (write_lookup_constraint): Special case two-character > constraints to also expand to a switch. > > Index: genpreds.c > =================================================================== > --- genpreds.c (revision 196053) > +++ genpreds.c (working copy) > @@ -941,6 +941,22 @@ write_lookup_constraint (void) > printf (" case '%c':\n", i); > if (c->namelen == 1) > printf (" return CONSTRAINT_%s;\n", c->c_name); > + else if (c->namelen == 2) > + { > + puts (" switch (str[1])\n" > + " {"); > + do > + { > + printf (" case '%c':\n" > + " return CONSTRAINT_%s;\n", > + c->name[1], c->c_name); > + c = c->next_this_letter; > + } > + while (c); > + puts (" default: break;\n" > + " }\n" > + " break;"); > + } > else > { > do
Patch
Index: genpreds.c =================================================================== --- genpreds.c (revision 196053) +++ genpreds.c (working copy) @@ -941,6 +941,22 @@ write_lookup_constraint (void) printf (" case '%c':\n", i); if (c->namelen == 1) printf (" return CONSTRAINT_%s;\n", c->c_name); + else if (c->namelen == 2) + { + puts (" switch (str[1])\n" + " {"); + do + { + printf (" case '%c':\n" + " return CONSTRAINT_%s;\n", + c->name[1], c->c_name); + c = c->next_this_letter; + } + while (c); + puts (" default: break;\n" + " }\n" + " break;"); + } else { do
Hi, from IRC: "[15:45:21] <richi> ick - lookup_constraint for multi-letter constraints is quite expensive ... strncmp is not expanded inline for some reason" Instead of fiddling with strncmp inlining, simply generate better code from the start for two character constraints: switch (str[0]) { case 'Y': switch (str[1]) { case 'i': return CONSTRAINT_Yi; case 'm': return CONSTRAINT_Ym; ... Ciao, Michael.