diff mbox

Speedup lookup_constraint for 2-letter constraints

Message ID alpine.LNX.2.00.1302191601500.3394@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Feb. 19, 2013, 3:07 p.m. UTC
This speeds up lookup_constraint by allowing the generic folding
for n == 1 strncmp calls to trigger, handling two-letter constraints
by two char comparisons instead of one and a call to strncmp (which
ends up not being inlined because it's considered cold ...).

Bootstrap & regtest pending on x86_64-unknown-linux-gnu.

Ok?

Thanks,
Richard.
2013-02-19  Richard Biener  <rguenther@suse.de>

	* genpreds.c (write_lookup_constraint): Do not compare first
	letter of the constraint again.

Comments

Jakub Jelinek Feb. 19, 2013, 3:09 p.m. UTC | #1
On Tue, Feb 19, 2013 at 04:07:49PM +0100, Richard Biener wrote:
> 
> This speeds up lookup_constraint by allowing the generic folding
> for n == 1 strncmp calls to trigger, handling two-letter constraints
> by two char comparisons instead of one and a call to strncmp (which
> ends up not being inlined because it's considered cold ...).
> 
> Bootstrap & regtest pending on x86_64-unknown-linux-gnu.
> 
> Ok?

Yes, thanks.

> 2013-02-19  Richard Biener  <rguenther@suse.de>
> 
> 	* genpreds.c (write_lookup_constraint): Do not compare first
> 	letter of the constraint again.

	Jakub
diff mbox

Patch

Index: gcc/genpreds.c
===================================================================
--- gcc/genpreds.c	(revision 196134)
+++ gcc/genpreds.c	(working copy)
@@ -945,9 +945,10 @@  write_lookup_constraint (void)
 	{
 	  do
 	    {
-	      printf ("      if (!strncmp (str, \"%s\", %lu))\n"
+	      printf ("      if (!strncmp (str + 1, \"%s\", %lu))\n"
 		      "        return CONSTRAINT_%s;\n",
-		      c->name, (unsigned long int) c->namelen, c->c_name);
+		      c->name + 1, (unsigned long int) c->namelen - 1,
+		      c->c_name);
 	      c = c->next_this_letter;
 	    }
 	  while (c);