--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-tree-fre -fdump-tree-phiprop-details" } */
+
+/* PR tree-optimization/124746 */
+
+struct a {
+ int b;
+} c, e = {1}, f;
+int d, g, j, *k = &d, n;
+static int i;
+static struct a *h = &e;
+int main() {
+ for (; n < 1; n++) {
+ int l;
+ struct a *m = &c;
+ L:
+ if (k) {
+ d = l = 0;
+ for (; l < 1; l++) {
+ j = i;
+ if (j) {
+ struct a **o = &m;
+ if (g)
+ goto L;
+ *o = &f;
+ }
+ }
+ } else
+ *h = *m;
+ }
+ if (e.b != 1)
+ __builtin_abort();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-not "Inserting PHI for result of load e =" "phiprop2" } } */
+
&& !gimple_has_volatile_ops (use_stmt)))
continue;
- if (canpossible_trap
+ bool aggregate = false;
+ if (!is_gimple_reg_type (TREE_TYPE (gimple_assign_lhs (use_stmt))))
+ aggregate = true;
+
+ if ((canpossible_trap || aggregate)
&& !dom_info_available_p (cfun, CDI_POST_DOMINATORS))
calculate_dominance_info (CDI_POST_DOMINATORS);
/* Only replace loads in blocks that post-dominate the PHI node. That
- makes sure we don't end up speculating trapping loads. */
- if (canpossible_trap
+ makes sure we don't end up speculating trapping loads or
+ aggregate stores won't happen speculating. */
+ if ((canpossible_trap || aggregate)
&& !dominated_by_p (CDI_POST_DOMINATORS,
bb, gimple_bb (use_stmt)))
delay = true;
/* Found a proper dereference with an aggregate copy. Just
insert aggregate copies on the edges instead. */
- if (!is_gimple_reg_type (TREE_TYPE (gimple_assign_lhs (use_stmt))))
+ if (aggregate)
{
/* aggregate copies are too hard to handled if delayed. */
if (delay)