This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Speedup recognizing multi-letter constraints


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]