+2011-01-25 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/47427
+ PR tree-optimization/47428
+ * tree-ssa-copyrename.c (copy_rename_partition_coalesce): Don't
+ coalesce if the new root var would be TREE_READONLY.
+
2011-01-25 Richard Guenther <rguenther@suse.de>
PR middle-end/47414
+2011-01-25 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/47427
+ PR tree-optimization/47428
+ * gcc.c-torture/compile/pr47427.c: New test.
+ * gcc.c-torture/compile/pr47428.c: New test.
+
2011-01-25 Richard Guenther <rguenther@suse.de>
PR middle-end/47411
--- /dev/null
+/* PR tree-optimization/47428 */
+
+struct S
+{
+ int s;
+} a;
+int b;
+
+void bar (struct S);
+
+int
+baz (int x __attribute__((unused)), int y)
+{
+ int i;
+ for (i = 0; i < 1; i = 1)
+ for (y = 0; y < 1; y = 1);
+ return y;
+}
+
+void
+foo (void)
+{
+ fn (0);
+}
+
+int
+fn (const int x, int y __attribute__((unused)))
+{
+ if (baz (baz (0, x), 0))
+ return 0;
+ else
+ bar (a);
+ return 0;
+}
+
+void
+bar (struct S x)
+{
+ for (;;)
+ for (; x.s;)
+ b = 0 ? : baz (0, 0);
+}
/* Rename SSA copies.
- Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010
+ Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Andrew MacLeod <amacleod@redhat.com>
return false;
}
- /* Never attempt to coalesce 2 difference parameters. */
+ /* Never attempt to coalesce 2 different parameters. */
if (TREE_CODE (root1) == PARM_DECL && TREE_CODE (root2) == PARM_DECL)
{
if (debug)
ign2 = false;
}
+ /* Don't coalesce if the new chosen root variable would be read-only.
+ If both ign1 && ign2, then the root var of the larger partition
+ wins, so reject in that case if any of the root vars is TREE_READONLY.
+ Otherwise reject only if the root var, on which replace_ssa_name_symbol
+ will be called below, is readonly. */
+ if ((TREE_READONLY (root1) && ign2) || (TREE_READONLY (root2) && ign1))
+ {
+ if (debug)
+ fprintf (debug, " : Readonly variable. No coalesce.\n");
+ return false;
+ }
+
/* Don't coalesce if the two variables aren't type compatible . */
if (!types_compatible_p (TREE_TYPE (root1), TREE_TYPE (root2))
/* There is a disconnect between the middle-end type-system and