patches/gcc/4.7.0/100-PR52734-tree-ssa-tail-merge.patch
author Yann Diorcet <diorcet.yann@gmail.com>
Mon Nov 19 21:45:09 2012 +0100 (2012-11-19)
changeset 3121 5016315d88ba
permissions -rw-r--r--
binutils/binutils: simplify gold dependencies

In preparation of adding a new kernel-type, Yann D. came up
with a change in semantic on binutils/gold availability.

So far, it was architectures' responsibility to declare that
they did support binutils/gold or not. It makes much more sense
that binutils/gold declares its own availability depending on
the current architecture; after all, architectures have no way
to know wether gold supports them, while gold does know it.

Signed-off-by:Yann Diorcet <diorcet.yann@gmail.com>
[yann.morin.1998@free.fr: split up original patch for self-contained changes]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Message-Id: <d3d1d51f399e6d2c1163.1353320546@macbook-smorlat.local>
Patchwork-Id: 199971
     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);