public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Remove dead code in genautomata.c
@ 2011-07-07 18:27 Bernd Schmidt
  2011-07-07 18:37 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Bernd Schmidt @ 2011-07-07 18:27 UTC (permalink / raw)
  To: GCC Patches; +Cc: Vladimir N. Makarov

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

In January 2006, Zack had a series of "chainsaw" patches for
genautomata. One of them left some dead code (a loop which used to count
states but is now useless), which the following patch removes.

Tested by verifying no warnings when compiling genautomata.c, and
identical insn-automata.c output for i686-linux and bfin-elf.  Ok?


Bernd

[-- Attachment #2: dc-ga.diff --]
[-- Type: text/plain, Size: 2442 bytes --]

	* genautomata.c (add_arc): Return void.  All callers changed.
	(make_automaton): Remove dead code.

Index: gcc/genautomata.c
===================================================================
--- gcc/genautomata.c	(revision 175906)
+++ gcc/genautomata.c	(working copy)
@@ -3908,16 +3908,16 @@ find_arc (state_t from_state, state_t to
   return NULL;
 }
 
-/* The function adds arc from FROM_STATE to TO_STATE marked by AINSN.
-   The function returns added arc (or already existing arc).  */
-static arc_t
+/* The function adds arc from FROM_STATE to TO_STATE marked by AINSN,
+   unless such an arc already exists.  */
+static void
 add_arc (state_t from_state, state_t to_state, ainsn_t ainsn)
 {
   arc_t new_arc;
 
   new_arc = find_arc (from_state, to_state, ainsn);
   if (new_arc != NULL)
-    return new_arc;
+    return;
   if (first_free_arc == NULL)
     {
 #ifndef NDEBUG
@@ -3940,7 +3940,6 @@ add_arc (state_t from_state, state_t to_
   from_state->first_out_arc = new_arc;
   from_state->num_out_arcs++;
   new_arc->next_arc_marked_by_insn = NULL;
-  return new_arc;
 }
 
 /* The function returns the first arc starting from STATE.  */
@@ -5464,7 +5463,6 @@ make_automaton (automaton_t automaton)
   state_t start_state;
   state_t state2;
   ainsn_t advance_cycle_ainsn;
-  arc_t added_arc;
   VEC(state_t, heap) *state_stack = VEC_alloc(state_t, heap, 150);
   int states_n;
   reserv_sets_t reservs_matter = form_reservs_matter (automaton);
@@ -5489,7 +5487,6 @@ make_automaton (automaton_t automaton)
               {
 		/* We process alt_states in the same order as they are
                    present in the description.  */
-		added_arc = NULL;
                 for (alt_state = ainsn->alt_states;
                      alt_state != NULL;
                      alt_state = alt_state->next_alt_state)
@@ -5507,18 +5504,11 @@ make_automaton (automaton_t automaton)
 			    if (progress_flag && states_n % 100 == 0)
 			      fprintf (stderr, ".");
                           }
-			added_arc = add_arc (state, state2, ainsn);
+			add_arc (state, state2, ainsn);
 			if (!ndfa_flag)
 			  break;
                       }
                   }
-		if (!ndfa_flag && added_arc != NULL)
-		  {
-		    for (alt_state = ainsn->alt_states;
-			 alt_state != NULL;
-			 alt_state = alt_state->next_alt_state)
-		      state2 = alt_state->state;
-		  }
               }
             else
               advance_cycle_ainsn = ainsn;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Remove dead code in genautomata.c
  2011-07-07 18:27 Remove dead code in genautomata.c Bernd Schmidt
@ 2011-07-07 18:37 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2011-07-07 18:37 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: GCC Patches, Vladimir N. Makarov

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/07/11 12:25, Bernd Schmidt wrote:
> In January 2006, Zack had a series of "chainsaw" patches for
> genautomata. One of them left some dead code (a loop which used to count
> states but is now useless), which the following patch removes.
> 
> Tested by verifying no warnings when compiling genautomata.c, and
> identical insn-automata.c output for i686-linux and bfin-elf.  Ok?
It's not obvious from the patch, but state2 is dead after that loop.

OK.
jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOFfybAAoJEBRtltQi2kC7PzgH/02VVTIHEzUrmZD1f1UJfz4F
633hgvlfGuunZ63+OzKJ+bVztK0Cml9s661l5EBS37F5JIba+l4H2kwrdpDdAoin
E5iZ+FL5qWzefYgtt4saie2ht+2U5W4CQBUw82qCZml+QlOrsftBdbL2nyIjQ0br
gbaQuNT2HNOYTQ9LXWRprTBwroColjHpdDcIBKr99hPiYgF1WziOKWaWq+qImwbZ
9G92iGCaas5vKq3aFinRzUXYOPHFy8CEtZjaSGn8ndPySwLI9ZRBEspDzaWh3kcK
7hQt26lUo//R9o8Ys5IKuWGPKM4wVAZtT8KhTMud+WENYuqA3hTBbmIX9t7K/bU=
=CyPM
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-07-07 18:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-07 18:27 Remove dead code in genautomata.c Bernd Schmidt
2011-07-07 18:37 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).