+2013-01-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/55920
+ * tree-sra.c (sra_modify_assign): If for lacc->grp_to_be_debug_replaced
+ there is non-useless type conversion needed from debug rhs to lhs,
+ use build_debug_ref_for_model and/or VIEW_CONVERT_EXPR.
+
2013-01-15 Joseph Myers <joseph@codesourcery.com>
Mikael Pettersson <mikpe@it.uu.se>
+2013-01-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/55920
+ * gcc.c-torture/compile/pr55920.c: New test.
+
2013-01-15 Richard Biener <rguenther@suse.de>
PR middle-end/55882
--- /dev/null
+/* PR tree-optimization/55920 */
+
+struct A { unsigned a; } __attribute__((packed));
+struct B { int b; unsigned char c[16]; };
+void bar (struct A);
+
+void
+foo (struct B *x)
+{
+ struct A a;
+ if (x->b)
+ __builtin_memcpy (&a, x->c, sizeof a);
+ else
+ a.a = 0;
+ bar (a);
+}
if (lacc && lacc->grp_to_be_debug_replaced)
{
- gimple ds = gimple_build_debug_bind (get_access_replacement (lacc),
- unshare_expr (rhs), *stmt);
+ tree dlhs = get_access_replacement (lacc);
+ tree drhs = unshare_expr (rhs);
+ if (!useless_type_conversion_p (TREE_TYPE (dlhs), TREE_TYPE (drhs)))
+ {
+ if (AGGREGATE_TYPE_P (TREE_TYPE (drhs))
+ && !contains_vce_or_bfcref_p (drhs))
+ drhs = build_debug_ref_for_model (loc, drhs, 0, lacc);
+ if (drhs
+ && !useless_type_conversion_p (TREE_TYPE (dlhs),
+ TREE_TYPE (drhs)))
+ drhs = fold_build1_loc (loc, VIEW_CONVERT_EXPR,
+ TREE_TYPE (dlhs), drhs);
+ }
+ gimple ds = gimple_build_debug_bind (dlhs, drhs, *stmt);
gsi_insert_before (gsi, ds, GSI_SAME_STMT);
}