PR tree-optimization/59287
* tree-ssa-structalias.c (get_constraint_for_component_ref):
Remove no longer necessary special-casing of union accesses.
* gcc.dg/tree-ssa/alias-29.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205380
138bc75d-0d04-0410-961f-
82ee72b054a4
2013-11-26 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/59287
+ * tree-ssa-structalias.c (get_constraint_for_component_ref):
+ Remove no longer necessary special-casing of union accesses.
+
+2013-11-26 Richard Biener <rguenther@suse.de>
+
* pretty-print.c (output_buffer::~output_buffer): Really
free the obstacks.
+2013-11-26 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/59287
+ * gcc.dg/tree-ssa/alias-29.c: New testcase.
+
2013-11-25 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54485
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+union X {
+ int i;
+ void *p;
+};
+void bar (int);
+
+int * __attribute__((noinline,noclone))
+baz (int *p) { return p; }
+
+void foo (union X *x)
+{
+ struct Y { int i; } ystruct = {};
+ ystruct.i = * baz (&ystruct.i);
+ bar (x->i);
+}
+
+/* DSE and then DCE should be able to remove all uses of ystruct.
+ Formerly the union access for the parameter to bar let 'anything'
+ escape which made the call to bar possibly use ystruct and thus
+ prevent the store to ystruct.i from being eliminated. The call to
+ baz makes sure that ystruct has its address taken. */
+
+/* { dg-final { scan-tree-dump-not "ystruct" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
return;
}
- /* Handle type-punning through unions. If we are extracting a pointer
- from a union via a possibly type-punning access that pointer
- points to anything, similar to a conversion of an integer to
- a pointer. */
- if (!lhs_p)
- {
- tree u;
- for (u = t;
- TREE_CODE (u) == COMPONENT_REF || TREE_CODE (u) == ARRAY_REF;
- u = TREE_OPERAND (u, 0))
- if (TREE_CODE (u) == COMPONENT_REF
- && TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE)
- {
- struct constraint_expr temp;
-
- temp.offset = 0;
- temp.var = anything_id;
- temp.type = ADDRESSOF;
- results->safe_push (temp);
- return;
- }
- }
-
t = get_ref_base_and_extent (t, &bitpos, &bitsize, &bitmaxsize);
/* Pretend to take the address of the base, we'll take care of