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.
-- 
        * 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

Reply via email to