diff mbox

[PR,57780] Waste work in subst_dup()

Message ID 654e83a55326637f306f9d4eacf8b31f.squirrel@webmail.cs.wisc.edu
State New
Headers show

Commit Message

pchang9@cs.wisc.edu July 23, 2013, 1:39 a.m. UTC
Hi,

The problem appears in revision 201034 in version 4.9.  I attached a
one-line patch that fixes it.  I also reported this problem
at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57780

Bootstrap and regression-tested on x86_64-linux.

In method "subst_dup()" in gensupport.c, the loop on line 2181
should not be executed when "code" equals to "MATCH_DUP" or "MATCH_OP_DUP".


2013-07-22  Chang  <pchang9@cs.wisc.edu>

        * gensupport.c (subst_dup): Avoid loop if code is not
        MATCH_DUP nor MATCH_OP_DUP.




-Chang
Index: gcc/gensupport.c
===================================================================
--- gcc/gensupport.c	(revision 201034)
+++ gcc/gensupport.c	(working copy)
@@ -2178,8 +2178,8 @@
 	  if (XVEC (pattern, i) == NULL)
 	    break;
 	case 'E':
-	  for (j = XVECLEN (pattern, i) - 1; j >= 0; --j)
-	    if (code != MATCH_DUP && code != MATCH_OP_DUP)
+	  if (code != MATCH_DUP && code != MATCH_OP_DUP)
+	    for (j = XVECLEN (pattern, i) - 1; j >= 0; --j)
 	      XVECEXP (pattern, i, j) = subst_dup (XVECEXP (pattern, i, j),
 						   n_alt, n_subst_alt);
 	  break;

Comments

Jeff Law July 23, 2013, 4:19 p.m. UTC | #1
On 07/22/2013 07:39 PM, pchang9@cs.wisc.edu wrote:
> Hi,
>
> The problem appears in revision 201034 in version 4.9.  I attached a
> one-line patch that fixes it.  I also reported this problem
> at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57780
>
> Bootstrap and regression-tested on x86_64-linux.
>
> In method "subst_dup()" in gensupport.c, the loop on line 2181
> should not be executed when "code" equals to "MATCH_DUP" or "MATCH_OP_DUP".
>
>
> 2013-07-22  Chang  <pchang9@cs.wisc.edu>
>
>          * gensupport.c (subst_dup): Avoid loop if code is not
>          MATCH_DUP nor MATCH_OP_DUP.
Thanks.  Installed.

We're probably getting to a point where the sum of all these fixes is 
going to require a copyright assignment.  If you could start that 
process with the FSF it would be greatly appreciated.

http://git.savannah.gnu.org/cgit/gnulib.git/tree/doc/Copyright/request-assign.future

You may also need an employer disclaimer.  assign@gnu.org can help you 
with ensuring you get the right paperwork.


It also seems to me you should get an account on gcc.gnu.org so that you 
can commit approved changes, close PRs, etc.

Here's the form.  List me as the sponsor/approver:


http://sourceware.org/cgi-bin/pdw/ps_form.cgi


You might also want to review:


http://gcc.gnu.org/svnwrite.html


Thanks again,

Jeff
diff mbox

Patch

Index: gcc/gensupport.c
===================================================================
--- gcc/gensupport.c	(revision 201034)
+++ gcc/gensupport.c	(working copy)
@@ -2178,8 +2178,8 @@ 
 	  if (XVEC (pattern, i) == NULL)
 	    break;
 	case 'E':
-	  for (j = XVECLEN (pattern, i) - 1; j >= 0; --j)
-	    if (code != MATCH_DUP && code != MATCH_OP_DUP)
+	  if (code != MATCH_DUP && code != MATCH_OP_DUP)
+	    for (j = XVECLEN (pattern, i) - 1; j >= 0; --j)
 	      XVECEXP (pattern, i, j) = subst_dup (XVECEXP (pattern, i, j),
 						   n_alt, n_subst_alt);
 	  break;