+2009-01-20 Andrew Pinski <andrew_pinski@playstation.sony.com>
+ Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/38747
+ PR tree-optimization/38748
+ * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Disable the VCE
+ conversion if the base address is an indirect reference and the
+ aliasing sets could cause issues.
+
2009-01-20 Sebastian Pop <sebastian.pop@amd.com>
* common.opt (fgraphite, fgraphite-identity): Add comment for
+2009-01-20 Andrew Pinski <andrew_pinski@playstation.sony.com>
+ Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/38747
+ PR tree-optimization/38748
+ * gcc.dg/tree-ssa/struct-aliasing-1.c: New test.
+ * gcc.dg/tree-ssa/struct-aliasing-2.c: Likewise.
+ * gcc.c-torture/execute/struct-aliasing-1.c: Likewise.
+
2009-01-20 Kees Cook <kees@ubuntu.com>
H.J. Lu <hongjiu.lu@intel.com>
--- /dev/null
+struct S { float f; };
+int __attribute__((noinline))
+foo (int *r, struct S *p)
+{
+ int *q = (int *)&p->f;
+ int i = *q;
+ *r = 0;
+ return i + *q;
+}
+extern void abort (void);
+int main()
+{
+ int i = 1;
+ if (foo (&i, (struct S *)&i) != 1)
+ abort ();
+ return (0);
+}
--- /dev/null
+/* { dg-do "compile" } */
+/* { dg-options "-O2 -fdump-tree-fre" } */
+
+struct S { float f; };
+int __attribute__((noinline))
+foo (float *r, struct S *p)
+{
+ int *q = (int *)&p->f;
+ int i = *q;
+ *r = 0.0;
+ return i + *q;
+}
+
+/* { dg-final { scan-tree-dump-times "\\\*q" 1 "fre" } } */
+/* { dg-final { cleanup-tree-dump "fre" } } */
--- /dev/null
+/* { dg-do "compile" } */
+/* { dg-options "-O2 -fdump-tree-fre" } */
+
+struct S { unsigned f; };
+
+int
+foo ( struct S *p)
+{
+ int *q = (int *)&p->f;
+ int i = *q;
+ return i + p->f;
+}
+
+
+/* There should only be one load of p->f because fwprop can change *(int *)&p->f into just (int)p->f. */
+/* { dg-final { scan-tree-dump-times "p_.\\\(D\\\)->f" 1 "fre" } } */
+/* { dg-final { cleanup-tree-dump "fre" } } */
+
&& operand_equal_p (TYPE_SIZE (TREE_TYPE (rhs)),
TYPE_SIZE (TREE_TYPE (TREE_OPERAND (def_rhs, 0))), 0))
{
- tree new_rhs = unshare_expr (TREE_OPERAND (def_rhs, 0));
+ tree def_rhs_base, new_rhs = unshare_expr (TREE_OPERAND (def_rhs, 0));
new_rhs = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (rhs), new_rhs);
if (TREE_CODE (new_rhs) != VIEW_CONVERT_EXPR)
{
new_rhs = force_gimple_operand_gsi (use_stmt_gsi, new_rhs, true, NULL,
true, GSI_NEW_STMT);
gimple_assign_set_rhs1 (use_stmt, new_rhs);
+ tidy_after_forward_propagate_addr (use_stmt);
+ return true;
}
- else
+ /* If the defining rhs comes from an indirect reference, then do not
+ convert into a VIEW_CONVERT_EXPR. */
+ def_rhs_base = TREE_OPERAND (def_rhs, 0);
+ while (handled_component_p (def_rhs_base))
+ def_rhs_base = TREE_OPERAND (def_rhs_base, 0);
+ if (!INDIRECT_REF_P (def_rhs_base))
{
/* We may have arbitrary VIEW_CONVERT_EXPRs in a nested component
reference. Place it there and fold the thing. */
*rhsp = new_rhs;
fold_stmt_inplace (use_stmt);
+ tidy_after_forward_propagate_addr (use_stmt);
+ return true;
}
- tidy_after_forward_propagate_addr (use_stmt);
- return true;
}
/* If the use of the ADDR_EXPR is not a POINTER_PLUS_EXPR, there