Commit f57f53d3 by Richard Biener Committed by Richard Biener

re PR middle-end/64516 (arm: wrong unaligned load generated)

2016-06-13  Richard Biener  <rguenther@suse.de>

	PR middle-end/64516
	* fold-const.c (fold_unary_loc): Preserve alignment when
	folding a VIEW_CONVERT_EXPR into a MEM_REF.

	* gcc.dg/align-3.c: New testcase.

From-SVN: r237355
parent f423253b
2016-06-13 Richard Biener <rguenther@suse.de>
PR middle-end/64516
* fold-const.c (fold_unary_loc): Preserve alignment when
folding a VIEW_CONVERT_EXPR into a MEM_REF.
2016-06-13 Martin Liska <mliska@suse.cz> 2016-06-13 Martin Liska <mliska@suse.cz>
PR sanitizer/71458 PR sanitizer/71458
......
...@@ -7975,6 +7975,8 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0) ...@@ -7975,6 +7975,8 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
case VIEW_CONVERT_EXPR: case VIEW_CONVERT_EXPR:
if (TREE_CODE (op0) == MEM_REF) if (TREE_CODE (op0) == MEM_REF)
{ {
if (TYPE_ALIGN (TREE_TYPE (op0)) != TYPE_ALIGN (type))
type = build_aligned_type (type, TYPE_ALIGN (TREE_TYPE (op0)));
tem = fold_build2_loc (loc, MEM_REF, type, tem = fold_build2_loc (loc, MEM_REF, type,
TREE_OPERAND (op0, 0), TREE_OPERAND (op0, 1)); TREE_OPERAND (op0, 0), TREE_OPERAND (op0, 1));
REF_REVERSE_STORAGE_ORDER (tem) = REF_REVERSE_STORAGE_ORDER (op0); REF_REVERSE_STORAGE_ORDER (tem) = REF_REVERSE_STORAGE_ORDER (op0);
......
2016-06-13 Richard Biener <rguenther@suse.de>
PR middle-end/64516
* gcc.dg/align-3.c: New testcase.
2016-06-13 Martin Liska <mliska@suse.cz> 2016-06-13 Martin Liska <mliska@suse.cz>
* gcc.target/i386/pr71458.c: New test. * gcc.target/i386/pr71458.c: New test.
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-rtl-expand" } */
typedef struct { char a[2]; } __attribute__((__packed__)) TU2;
unsigned short get16_unaligned(const void *p) {
unsigned short v;
*(TU2 *)(void *)(&v) = *(const TU2 *)p;
return v;
}
/* { dg-final { scan-rtl-dump "MEM\[^\n\r\]*A8\\\]" "expand" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment