------- Comment #17 from rguenth at gcc dot gnu dot org 2010-07-26 12:21
-------
One of the issues is
/* For a MEM rtx, the alignment in bits. We can use the alignment of the
mode as a default when STRICT_ALIGNMENT, but not if not. */
#define MEM_ALIGN(RTX) \
(MEM_ATTRS (RTX) != 0 ? MEM_ATTRS (RTX)->align \
: (STRICT_ALIGNMENT && GET_MODE (RTX) != BLKmode \
? GET_MODE_ALIGNMENT (GET_MODE (RTX)) : BITS_PER_UNIT))
this might be true during RTL, but certainly during expansion this is wrong.
It invents alignment out of thin air.
Invented by Kenner via
+Tue Oct 23 13:05:53 2001 Richard Kenner <[email protected]>
+
...
+ * rtl.h (MEM_ALIGN): Take default from mode, if not BLKmode, and
+ change default if unknown from 1 to BITS_PER_UNIT.
and "fixed up" partly
+Sun Jan 27 13:23:40 2002 Richard Kenner <[email protected]>
+
+ * emit-rtl.c (get_mem_attrs): Don't default alignment for non-BLKmode
+ if not STRICT_ALIGNMENT.
+ * rtl.h (MEM_ALIGN): Likewise.
which conditionalized it on STRICT_ALIGNMENT.
But store_field still tries to compare MEM_ALIGN for alignment. This
could have never worked properly.
Thus, for stores I can "fix" it by doing
Index: gcc/emit-rtl.c
===================================================================
--- gcc/emit-rtl.c (revision 162526)
+++ gcc/emit-rtl.c (working copy)
@@ -1543,7 +1543,7 @@ set_mem_attributes_minus_bitpos (rtx ref
tree expr = MEM_EXPR (ref);
rtx offset = MEM_OFFSET (ref);
rtx size = MEM_SIZE (ref);
- unsigned int align = MEM_ALIGN (ref);
+ unsigned int align = MEM_ATTRS (ref) ? MEM_ALIGN (ref) : BITS_PER_UNIT;
HOST_WIDE_INT apply_bitpos = 0;
tree type;
Index: gcc/expr.c
===================================================================
--- gcc/expr.c (revision 162526)
+++ gcc/expr.c (working copy)
@@ -4168,7 +4168,7 @@ expand_assignment (tree to, tree from, b
Assignment of an array element at a constant index, and assignment of
an array element in an unaligned packed structure field, has the same
problem. */
- if (handled_component_p (to)
+ if (1 || handled_component_p (to)
/* ??? We only need to handle MEM_REF here if the access is not
a full access of the base object. */
|| (TREE_CODE (to) == MEM_REF
but unaligned loads are not fixed by that.
Pre-existing mess. I am not qualified to stir it more.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|rguenth at gcc dot gnu dot |unassigned at gcc dot gnu
|org |dot org
Status|ASSIGNED |NEW
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44903