[PR57803] Wasted work in gfc_build_dummy_array_decl()
diff mbox

Message ID 3b98e0fc39b803e4611dad05371309f7.squirrel@webmail.cs.wisc.edu
State New
Headers show

Commit Message

pchang9@cs.wisc.edu July 19, 2013, 10:59 p.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=57803

I bootstrapped and ran the regression tests for this patch on x86_64-linux
and all tests pass.

In method "gfc_build_dummy_array_decl()" in gcc/fortran/trans-decl.c,
the loop on line 978 should break immediately after "packed" is set to
"PACKED_PARTIAL". All the iterations after "packed" set to
"PACKED_PARTIAL" do not perform any useful work, at best they just set
"packed" again to "PACKED_PARTIAL".



-Chang
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c	(revision 201034)
+++ gcc/fortran/trans-decl.c	(working copy)
@@ -975,7 +975,10 @@
 			&& as->lower[n]
 			&& as->upper[n]->expr_type == EXPR_CONSTANT
 			&& as->lower[n]->expr_type == EXPR_CONSTANT))
-		    packed = PACKED_PARTIAL;
+		    {
+		      packed = PACKED_PARTIAL;
+		      break;
+		    }
 		}
 	    }
 	  else

Comments

Jeff Law July 22, 2013, 3:22 p.m. UTC | #1
On 07/19/2013 04:59 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=57803
>
> I bootstrapped and ran the regression tests for this patch on x86_64-linux
> and all tests pass.
>
> In method "gfc_build_dummy_array_decl()" in gcc/fortran/trans-decl.c,
> the loop on line 978 should break immediately after "packed" is set to
> "PACKED_PARTIAL". All the iterations after "packed" set to
> "PACKED_PARTIAL" do not perform any useful work, at best they just set
> "packed" again to "PACKED_PARTIAL".
Thanks.  I've installed the patches from all of your emails which 
address these issues.

I'm a bit curious, are you finding these by inspection of the sources or 
via some kind of analysis code?

Thanks again,
Jeff

Patch
diff mbox

Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c	(revision 201034)
+++ gcc/fortran/trans-decl.c	(working copy)
@@ -975,7 +975,10 @@ 
 			&& as->lower[n]
 			&& as->upper[n]->expr_type == EXPR_CONSTANT
 			&& as->lower[n]->expr_type == EXPR_CONSTANT))
-		    packed = PACKED_PARTIAL;
+		    {
+		      packed = PACKED_PARTIAL;
+		      break;
+		    }
 		}
 	    }
 	  else