1 ------------------------------------------------------------------------
2 r186424 | vries | 2012-04-13 18:44:18 +0200 (Fri, 13 Apr 2012) | 12 lines
4 2012-04-13 Tom de Vries <tom@codesourcery.com>
6 Backport from mainline r186418.
8 2012-04-13 Tom de Vries <tom@codesourcery.com>
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
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 @@
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. */
31 -gsi_advance_bw_nondebug_nonlocal (gimple_stmt_iterator *gsi)
32 +gsi_advance_bw_nondebug_nonlocal (gimple_stmt_iterator *gsi, tree *vuse,
42 stmt = gsi_stmt (*gsi);
44 + lvuse = gimple_vuse (stmt);
45 + if (lvuse != NULL_TREE)
48 + if (!ZERO_SSA_OPERANDS (stmt, SSA_OP_DEF))
49 + *vuse_escaped = true;
52 if (!(is_gimple_assign (stmt) && local_def (gimple_get_lhs (stmt))
53 && !gimple_has_side_effects (stmt)))
55 @@ -1150,9 +1163,11 @@
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;
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);
67 while (!gsi_end_p (gsi1) && !gsi_end_p (gsi2))
69 @@ -1161,13 +1176,20 @@
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);
79 if (!(gsi_end_p (gsi1) && gsi_end_p (gsi2)))
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)
90 fprintf (dump_file, "find_duplicates: <bb %d> duplicate of <bb %d>\n",
91 bb1->index, bb2->index);