+2010-01-28 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/42871
+ * tree-ssa-pre.c (phi_translate_set): Make sure to retain
+ leaders.
+
2010-01-28 Richard Guenther <rguenther@suse.de>
* tree-ssa-ccp.c (ccp_fold_stmt): Fold calls and propagate
+2010-01-28 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/42871
+ * g++.dg/torture/pr42871.C: New testcase.
+
2010-01-28 Richard Guenther <rguenther@suse.de>
* gcc.dg/Wobjsize-1.h: New testcase.
--- /dev/null
+struct C
+{
+ ~C ();
+ int c3;
+};
+
+C *b2;
+
+static void
+b1 (const C &x, unsigned b3, unsigned b4)
+{
+ unsigned i = 0;
+ for (; i < b3; i++)
+ if (i < b4)
+ {
+ b2[0].c3 = x.c3;
+ return;
+ }
+}
+
+int a ();
+
+void
+bar (unsigned b3, unsigned b4)
+{
+ C c[100];
+ for (int i = 0; i < 100; i++)
+ {
+ c[i].c3 = i;
+ for (int j = 0; j < b3; j++)
+ if (j < b4)
+ {
+ b2[0].c3 = 0;
+ break;
+ }
+ b1 (c[i], b3, b4);
+ a ();
+ }
+}
+
translated = phi_translate (expr, set, NULL, pred, phiblock);
/* Don't add empty translations to the cache */
- if (translated)
- phi_trans_add (expr, translated, pred);
+ if (!translated)
+ continue;
+
+ phi_trans_add (expr, translated, pred);
- if (translated != NULL)
+ /* We might end up with multiple expressions from SET being
+ translated to the same value. In this case we do not want
+ to retain the NARY or REFERENCE expression but prefer a NAME
+ which would be the leader. */
+ if (translated->kind == NAME)
+ bitmap_value_replace_in_set (dest, translated);
+ else
bitmap_value_insert_into_set (dest, translated);
}
VEC_free (pre_expr, heap, exprs);