+2014-03-17 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2013-05-21 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/57303
+ * tree-ssa-sink.c (statement_sink_location): Properly handle
+ self-assignments.
+
+ 2013-12-02 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/59139
+ * tree-ssa-loop-niter.c (chain_of_csts_start): Properly match
+ code in get_val_for.
+ (get_val_for): Use gcc_checking_asserts.
+
+ 2014-02-14 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/60183
+ * tree-ssa-phiprop.c (propagate_with_phi): Avoid speculating
+ loads.
+ (tree_ssa_phiprop): Calculate and free post-dominators.
+
2014-03-14 Georg-Johann Lay <avr@gjlay.de>
Backport from 2014-03-14 trunk r208562.
+2014-03-17 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2013-05-21 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/57303
+ * gcc.dg/torture/pr57303.c: New testcase.
+
+ 2013-12-02 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/59139
+ * gcc.dg/torture/pr59139.c: New testcase.
+
+ 2014-02-14 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/60183
+ * gcc.dg/torture/pr60183.c: New testcase.
+
2014-03-15 Jerry DeLisle <jvdelisle@gcc.gnu>
Backport from mainline
--- /dev/null
+/* { dg-do run } */
+
+void abort (void);
+
+struct S0
+{
+ int f0;
+};
+struct S1
+{
+ struct S0 f0;
+};
+
+struct S1 x = { {0} };
+struct S1 y = { {1} };
+
+static void
+foo (struct S0 p)
+{
+ struct S0 *l = &y.f0;
+ *l = x.f0;
+ if (p.f0)
+ *l = *l;
+}
+
+int
+main ()
+{
+ foo(y.f0);
+ if (y.f0.f0 != 0)
+ abort ();
+ return 0;
+}
--- /dev/null
+/* { dg-do compile } */
+
+int a, b, c, d, e;
+int fn1(p1, p2) { return p2 == 0 ? p1 : 1 % p2; }
+
+void fn2()
+{
+ c = 0;
+ for (;; c = (unsigned short)c)
+ {
+ b = 2;
+ for (; b; b = a)
+ {
+ e = fn1(2, c && 1);
+ d = c == 0 ? e : c;
+ if (d)
+ return;
+ }
+ }
+}
--- /dev/null
+/* { dg-do run } */
+/* { dg-require-effective-target size32plus } */
+
+/* Large so an out-of-bound read will crash. */
+unsigned char c[0x30001] = { 1 };
+int j = 2;
+
+static void
+foo (unsigned long *x, unsigned char *y)
+{
+ int i;
+ unsigned long w = x[0];
+ for (i = 0; i < j; i++)
+ {
+ w += *y;
+ y += 0x10000;
+ w += *y;
+ y += 0x10000;
+ }
+ x[1] = w;
+}
+
+__attribute__ ((noinline, noclone)) void
+bar (unsigned long *x)
+{
+ foo (x, c);
+}
+
+int
+main ()
+{
+ unsigned long a[2] = { 0, -1UL };
+ asm volatile (""::"r" (c):"memory");
+ c[0] = 0;
+ bar (a);
+ if (a[1] != 0)
+ __builtin_abort ();
+ return 0;
+}
return NULL;
}
- if (gimple_code (stmt) != GIMPLE_ASSIGN)
+ if (gimple_code (stmt) != GIMPLE_ASSIGN
+ || gimple_assign_rhs_class (stmt) == GIMPLE_TERNARY_RHS)
return NULL;
code = gimple_assign_rhs_code (stmt);
{
gimple stmt;
- gcc_assert (is_gimple_min_invariant (base));
+ gcc_checking_assert (is_gimple_min_invariant (base));
if (!x)
return base;
if (gimple_code (stmt) == GIMPLE_PHI)
return base;
- gcc_assert (is_gimple_assign (stmt));
+ gcc_checking_assert (is_gimple_assign (stmt));
/* STMT must be either an assignment of a single SSA name or an
expression involving an SSA name and a constant. Try to fold that
gimple def_stmt;
tree vuse;
+ /* Only replace loads in blocks that post-dominate the PHI node. That
+ makes sure we don't end up speculating loads. */
+ if (!dominated_by_p (CDI_POST_DOMINATORS,
+ bb, gimple_bb (use_stmt)))
+ continue;
+
/* Check whether this is a load of *ptr. */
if (!(is_gimple_assign (use_stmt)
&& TREE_CODE (gimple_assign_lhs (use_stmt)) == SSA_NAME
size_t n;
calculate_dominance_info (CDI_DOMINATORS);
+ calculate_dominance_info (CDI_POST_DOMINATORS);
n = num_ssa_names;
phivn = XCNEWVEC (struct phiprop_d, n);
VEC_free (basic_block, heap, bbs);
free (phivn);
+ free_dominance_info (CDI_POST_DOMINATORS);
+
return 0;
}
&& gimple_vdef (use_stmt)
&& operand_equal_p (gimple_assign_lhs (stmt),
gimple_assign_lhs (use_stmt), 0))
- continue;
+ {
+ /* If use_stmt is or might be a nop assignment then USE_STMT
+ acts as a use as well as definition. */
+ if (stmt != use_stmt
+ && ref_maybe_used_by_stmt_p (use_stmt,
+ gimple_assign_lhs (stmt)))
+ return false;
+ continue;
+ }
if (gimple_code (use_stmt) != GIMPLE_PHI)
return false;