public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [lto] remove unnecessary assignment
@ 2016-08-26 13:00 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2016-08-26 13:00 UTC (permalink / raw)
  To: GCC Patches; +Cc: Richard Guenther

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

In chasing down an LTO read/write bug I came across some 'interesting' code in 
inline_write_summaries:

    if (cnode && (node = cnode)->definition && !node->alias)

that in-test assignment isn't needed -- cnode is not modified until the next 
loop iteration.

Fixed as obvious by removing the 'node' variable.

nathan

[-- Attachment #2: ipa.patch --]
[-- Type: text/x-patch, Size: 2084 bytes --]

2016-08-26  Nathan Sidwell  <nathan@acm.org>

	* ipa-inline-analysis.c (inline_write_summary): Remove unnecessary
	assignment inside if condition.

Index: ipa-inline-analysis.c
===================================================================
--- ipa-inline-analysis.c	(revision 239778)
+++ ipa-inline-analysis.c	(working copy)
@@ -4430,7 +4430,6 @@ write_inline_edge_summary (struct output
 void
 inline_write_summary (void)
 {
-  struct cgraph_node *node;
   struct output_block *ob = create_output_block (LTO_section_inline_summary);
   lto_symtab_encoder_t encoder = ob->decl_state->symtab_node_encoder;
   unsigned int count = 0;
@@ -4449,19 +4448,16 @@ inline_write_summary (void)
     {
       symtab_node *snode = lto_symtab_encoder_deref (encoder, i);
       cgraph_node *cnode = dyn_cast <cgraph_node *> (snode);
-      if (cnode && (node = cnode)->definition && !node->alias)
+      if (cnode && cnode->definition && !cnode->alias)
 	{
-	  struct inline_summary *info = inline_summaries->get (node);
+	  struct inline_summary *info = inline_summaries->get (cnode);
 	  struct bitpack_d bp;
 	  struct cgraph_edge *edge;
 	  int i;
 	  size_time_entry *e;
 	  struct condition *c;
 
-	  streamer_write_uhwi (ob,
-			       lto_symtab_encoder_encode (encoder,
-							  
-							  node));
+	  streamer_write_uhwi (ob, lto_symtab_encoder_encode (encoder, cnode));
 	  streamer_write_hwi (ob, info->estimated_self_stack_size);
 	  streamer_write_hwi (ob, info->self_size);
 	  streamer_write_hwi (ob, info->self_time);
@@ -4494,9 +4490,9 @@ inline_write_summary (void)
 	  write_predicate (ob, info->loop_iterations);
 	  write_predicate (ob, info->loop_stride);
 	  write_predicate (ob, info->array_index);
-	  for (edge = node->callees; edge; edge = edge->next_callee)
+	  for (edge = cnode->callees; edge; edge = edge->next_callee)
 	    write_inline_edge_summary (ob, edge);
-	  for (edge = node->indirect_calls; edge; edge = edge->next_callee)
+	  for (edge = cnode->indirect_calls; edge; edge = edge->next_callee)
 	    write_inline_edge_summary (ob, edge);
 	}
     }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-26 13:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-26 13:00 [lto] remove unnecessary assignment Nathan Sidwell

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).