re PR tree-optimization/83141 (SRA and memcpy folding interact badly generating wrong-code)

2017-11-28  Richard Biener  <rguenther@suse.de>

	PR middle-end/83141
	* gimple-fold.c (gimple_fold_builtin_memory_op): For aggregate
	copies generated from memcpy use a character array as reference
	type.

From-SVN: r255197
This commit is contained in:
Richard Biener 2017-11-28 11:58:45 +00:00 committed by Richard Biener
parent fa69d74bd8
commit d725717165
2 changed files with 24 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2017-11-28 Richard Biener <rguenther@suse.de>
PR middle-end/83141
* gimple-fold.c (gimple_fold_builtin_memory_op): For aggregate
copies generated from memcpy use a character array as reference
type.
2017-11-28 Julia Koval <julia.koval@intel.com>
Sebastian Peryt <sebastian.peryt@intel.com>

View File

@ -1039,8 +1039,24 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
gimple_set_vuse (new_stmt, gimple_vuse (stmt));
gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT);
}
new_stmt = gimple_build_assign (destvar, srcvar);
goto set_vop_and_replace;
}
new_stmt = gimple_build_assign (destvar, srcvar);
/* We get an aggregate copy. Use an unsigned char[] type to
perform the copying to preserve padding and to avoid any issues
with TREE_ADDRESSABLE types or float modes behavior on copying. */
desttype = build_array_type_nelts (unsigned_char_type_node,
tree_to_uhwi (len));
srctype = desttype;
if (src_align > TYPE_ALIGN (srctype))
srctype = build_aligned_type (srctype, src_align);
if (dest_align > TYPE_ALIGN (desttype))
desttype = build_aligned_type (desttype, dest_align);
new_stmt
= gimple_build_assign (fold_build2 (MEM_REF, desttype, dest, off0),
fold_build2 (MEM_REF, srctype, src, off0));
set_vop_and_replace:
gimple_set_vuse (new_stmt, gimple_vuse (stmt));
gimple_set_vdef (new_stmt, gimple_vdef (stmt));
if (gimple_vdef (new_stmt)