- if (objectp || TREE_CODE (t) == INDIRECT_REF
- || TREE_CODE (t) == ALIGN_INDIRECT_REF
- || TYPE_ALIGN_OK (type))
- align = MAX (align, TYPE_ALIGN (type));
- else
- if (TREE_CODE (t) == MISALIGNED_INDIRECT_REF)
- {
- if (integer_zerop (TREE_OPERAND (t, 1)))
- /* We don't know anything about the alignment. */
- align = BITS_PER_UNIT;
- else
- align = tree_low_cst (TREE_OPERAND (t, 1), 1);
- }
+ if (objectp || TREE_CODE (t) == INDIRECT_REF || TYPE_ALIGN_OK (type))
+ attrs.align = MAX (attrs.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)))
+ attrs.align = DECL_ALIGN (TREE_OPERAND (op0, 0));
+ else if (CONSTANT_CLASS_P (TREE_OPERAND (op0, 0)))
+ {
+ attrs.align = TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (op0, 0)));
+#ifdef CONSTANT_ALIGNMENT
+ attrs.align = CONSTANT_ALIGNMENT (TREE_OPERAND (op0, 0),
+ attrs.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;
+ attrs.align = MIN (aoff, attrs.align);
+ }
+ }
+ else
+ /* ??? This isn't fully correct, we can't set the alignment from the
+ type in all cases. */
+ attrs.align = MAX (attrs.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. */
+ attrs.align = MAX (attrs.align, TYPE_ALIGN (type));