http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47397
--- Comment #10 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-21 16:21:55 UTC --- You can play with a cleanup patch I have lying around, queued for 4.7: Index: emit-rtl.c =================================================================== *** emit-rtl.c (revision 169088) --- emit-rtl.c (working copy) *************** set_mem_attributes_minus_bitpos (rtx ref *** 1611,1654 **** /* We can set the alignment from the type if we are making an object, this is an INDIRECT_REF, or if TYPE_ALIGN_OK. */ ! if (objectp || TREE_CODE (t) == INDIRECT_REF || TYPE_ALIGN_OK (type)) ! align = MAX (align, TYPE_ALIGN (type)); ! ! else if (TREE_CODE (t) == MEM_REF) { ! tree op0 = TREE_OPERAND (t, 0); ! if (TREE_CODE (op0) == ADDR_EXPR ! && (DECL_P (TREE_OPERAND (op0, 0)) ! || CONSTANT_CLASS_P (TREE_OPERAND (op0, 0)))) ! { ! if (DECL_P (TREE_OPERAND (op0, 0))) ! align = DECL_ALIGN (TREE_OPERAND (op0, 0)); ! else if (CONSTANT_CLASS_P (TREE_OPERAND (op0, 0))) ! { ! align = TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (op0, 0))); ! #ifdef CONSTANT_ALIGNMENT ! align = CONSTANT_ALIGNMENT (TREE_OPERAND (op0, 0), align); ! #endif ! } ! if (TREE_INT_CST_LOW (TREE_OPERAND (t, 1)) != 0) ! { ! unsigned HOST_WIDE_INT ioff ! = TREE_INT_CST_LOW (TREE_OPERAND (t, 1)); ! unsigned HOST_WIDE_INT aoff = (ioff & -ioff) * BITS_PER_UNIT; ! align = MIN (aoff, align); ! } ! } ! else /* ??? This isn't fully correct, we can't set the alignment from the type in all cases. */ align = MAX (align, TYPE_ALIGN (type)); } - else if (TREE_CODE (t) == TARGET_MEM_REF) - /* ??? This isn't fully correct, we can't set the alignment from the - type in all cases. */ - align = MAX (align, TYPE_ALIGN (type)); - /* If the size is known, we can set that. */ if (TYPE_SIZE_UNIT (type) && host_integerp (TYPE_SIZE_UNIT (type), 1)) size = GEN_INT (tree_low_cst (TYPE_SIZE_UNIT (type), 1)); --- 1611,1628 ---- /* We can set the alignment from the type if we are making an object, this is an INDIRECT_REF, or if TYPE_ALIGN_OK. */ ! if (!TYPE_P (t)) { ! align = MAX (align, get_object_alignment (t, BIGGEST_ALIGNMENT)); ! if (objectp || TYPE_ALIGN_OK (type)) ! align = MAX (align, TYPE_ALIGN (type)); ! else if (TREE_CODE (t) == TARGET_MEM_REF ! || TREE_CODE (t) == MEM_REF) /* ??? This isn't fully correct, we can't set the alignment from the type in all cases. */ align = MAX (align, TYPE_ALIGN (type)); } /* If the size is known, we can set that. */ if (TYPE_SIZE_UNIT (type) && host_integerp (TYPE_SIZE_UNIT (type), 1)) size = GEN_INT (tree_low_cst (TYPE_SIZE_UNIT (type), 1)); but I wonder why we are not falling into the - else if (TREE_CODE (t) == TARGET_MEM_REF) - /* ??? This isn't fully correct, we can't set the alignment from the - type in all cases. */ - align = MAX (align, TYPE_ALIGN (type)); case right now, or what I am missing. Ah, for the offsetted load the vectorizer uses a 64bit aligned type. So it either cannot compute the alignment or fails to use an aligned type.