patches/gcc/4.7.0/100-PR52734-tree-ssa-tail-merge.patch
author "Bryan Hundven" <bryanhundven@gmail.com>
Fri Mar 23 01:36:42 2012 -0700 (2012-03-23)
changeset 2943 ededa826097f
permissions -rw-r--r--
cc/gcc: add gcc-4.7.0

Add the new release gcc-4.7.0.

Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
[yann.morin.1998@free.fr: add 4.7.0 patch]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
     1 ------------------------------------------------------------------------
     2 r186424 | vries | 2012-04-13 18:44:18 +0200 (Fri, 13 Apr 2012) | 12 lines
     3 
     4 2012-04-13  Tom de Vries  <tom@codesourcery.com>
     5 
     6 	Backport from mainline r186418.
     7 
     8 	2012-04-13  Tom de Vries  <tom@codesourcery.com>
     9 
    10 	* tree-ssa-tail-merge.c (gsi_advance_bw_nondebug_nonlocal): Add
    11 	parameters vuse and vuse_escaped.
    12 	(find_duplicate): Init vuse1, vuse2 and vuse_escaped.  Pass to
    13 	gsi_advance_bw_nondebug_nonlocal.  Return if vuse_escaped and
    14 	vuse1 != vuse2.
    15 
    16 ------------------------------------------------------------------------
    17 Index: gcc/tree-ssa-tail-merge.c
    18 ===================================================================
    19 --- gcc-4.7.0/gcc/tree-ssa-tail-merge.c	(revision 186423)
    20 +++ gcc-4.7.0/gcc/tree-ssa-tail-merge.c	(revision 186424)
    21 @@ -1123,18 +1123,31 @@
    22      }
    23  }
    24  
    25 -/* Let GSI skip backwards over local defs.  */
    26 +/* Let GSI skip backwards over local defs.  Return the earliest vuse in VUSE.
    27 +   Return true in VUSE_ESCAPED if the vuse influenced a SSA_OP_DEF of one of the
    28 +   processed statements.  */
    29  
    30  static void
    31 -gsi_advance_bw_nondebug_nonlocal (gimple_stmt_iterator *gsi)
    32 +gsi_advance_bw_nondebug_nonlocal (gimple_stmt_iterator *gsi, tree *vuse,
    33 +				  bool *vuse_escaped)
    34  {
    35    gimple stmt;
    36 +  tree lvuse;
    37  
    38    while (true)
    39      {
    40        if (gsi_end_p (*gsi))
    41  	return;
    42        stmt = gsi_stmt (*gsi);
    43 +
    44 +      lvuse = gimple_vuse (stmt);
    45 +      if (lvuse != NULL_TREE)
    46 +	{
    47 +	  *vuse = lvuse;
    48 +	  if (!ZERO_SSA_OPERANDS (stmt, SSA_OP_DEF))
    49 +	    *vuse_escaped = true;
    50 +	}
    51 +
    52        if (!(is_gimple_assign (stmt) && local_def (gimple_get_lhs (stmt))
    53  	    && !gimple_has_side_effects (stmt)))
    54  	return;
    55 @@ -1150,9 +1163,11 @@
    56  {
    57    gimple_stmt_iterator gsi1 = gsi_last_nondebug_bb (bb1);
    58    gimple_stmt_iterator gsi2 = gsi_last_nondebug_bb (bb2);
    59 +  tree vuse1 = NULL_TREE, vuse2 = NULL_TREE;
    60 +  bool vuse_escaped = false;
    61  
    62 -  gsi_advance_bw_nondebug_nonlocal (&gsi1);
    63 -  gsi_advance_bw_nondebug_nonlocal (&gsi2);
    64 +  gsi_advance_bw_nondebug_nonlocal (&gsi1, &vuse1, &vuse_escaped);
    65 +  gsi_advance_bw_nondebug_nonlocal (&gsi2, &vuse2, &vuse_escaped);
    66  
    67    while (!gsi_end_p (gsi1) && !gsi_end_p (gsi2))
    68      {
    69 @@ -1161,13 +1176,20 @@
    70  
    71        gsi_prev_nondebug (&gsi1);
    72        gsi_prev_nondebug (&gsi2);
    73 -      gsi_advance_bw_nondebug_nonlocal (&gsi1);
    74 -      gsi_advance_bw_nondebug_nonlocal (&gsi2);
    75 +      gsi_advance_bw_nondebug_nonlocal (&gsi1, &vuse1, &vuse_escaped);
    76 +      gsi_advance_bw_nondebug_nonlocal (&gsi2, &vuse2, &vuse_escaped);
    77      }
    78  
    79    if (!(gsi_end_p (gsi1) && gsi_end_p (gsi2)))
    80      return;
    81  
    82 +  /* If the incoming vuses are not the same, and the vuse escaped into an
    83 +     SSA_OP_DEF, then merging the 2 blocks will change the value of the def,
    84 +     which potentially means the semantics of one of the blocks will be changed.
    85 +     TODO: make this check more precise.  */
    86 +  if (vuse_escaped && vuse1 != vuse2)
    87 +    return;
    88 +
    89    if (dump_file)
    90      fprintf (dump_file, "find_duplicates: <bb %d> duplicate of <bb %d>\n",
    91  	     bb1->index, bb2->index);