diff options
author | Eric Botcazou <ebotcazou@act-europe.fr> | 2004-03-08 07:48:51 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2004-03-08 06:48:51 +0000 |
commit | d50a16c4335e68f36982ab6e2de8744d6bcd101d (patch) | |
tree | fa9e3e9dcafa91608c9e55c39fab6204b9942a22 /gcc | |
parent | b1917422afdc729bafd42f01433fd4d0e2cdf760 (diff) | |
download | gcc-d50a16c4335e68f36982ab6e2de8744d6bcd101d.zip gcc-d50a16c4335e68f36982ab6e2de8744d6bcd101d.tar.gz gcc-d50a16c4335e68f36982ab6e2de8744d6bcd101d.tar.bz2 |
expr.c (highest_pow2_factor_for_type): Rename into highest_pow2_factor_for_target.
* expr.c (highest_pow2_factor_for_type): Rename into
highest_pow2_factor_for_target. Use DECL_ALIGN instead of
TYPE_ALIGN when the target is a COMPONENT_REF.
(expand_assignment): Ajust call to highest_pow2_factor_for_type.
From-SVN: r79101
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/expr.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/20040308-1.c | 21 |
4 files changed, 46 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0ca4fbf..f080f05 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2004-03-08 Eric Botcazou <ebotcazou@act-europe.fr> + + * expr.c (highest_pow2_factor_for_type): Rename into + highest_pow2_factor_for_target. Use DECL_ALIGN instead of + TYPE_ALIGN when the target is a COMPONENT_REF. + (expand_assignment): Ajust call to highest_pow2_factor_for_type. + 2004-03-08 Alan Modra <amodra@bigpond.net.au> * config/rs6000/rs6000.c: Formatting fix. @@ -156,7 +156,7 @@ static rtx store_field (rtx, HOST_WIDE_INT, HOST_WIDE_INT, enum machine_mode, static rtx var_rtx (tree); static unsigned HOST_WIDE_INT highest_pow2_factor (tree); -static unsigned HOST_WIDE_INT highest_pow2_factor_for_type (tree, tree); +static unsigned HOST_WIDE_INT highest_pow2_factor_for_target (tree, tree); static int is_aligning_offset (tree, tree); static rtx expand_increment (tree, int, int); @@ -3800,8 +3800,8 @@ expand_assignment (tree to, tree from, int want_value) } to_rtx = offset_address (to_rtx, offset_rtx, - highest_pow2_factor_for_type (TREE_TYPE (to), - offset)); + highest_pow2_factor_for_target (to, + offset)); } if (GET_CODE (to_rtx) == MEM) @@ -6049,17 +6049,22 @@ highest_pow2_factor (tree exp) return 1; } -/* Similar, except that it is known that the expression must be a multiple - of the alignment of TYPE. */ +/* Similar, except that the alignment requirements of TARGET are + taken into account. Assume it is at least as aligned as its + type, unless it is a COMPONENT_REF in which case the layout of + the structure gives the alignment. */ static unsigned HOST_WIDE_INT -highest_pow2_factor_for_type (tree type, tree exp) +highest_pow2_factor_for_target (tree target, tree exp) { - unsigned HOST_WIDE_INT type_align, factor; + unsigned HOST_WIDE_INT target_align, factor; factor = highest_pow2_factor (exp); - type_align = TYPE_ALIGN (type) / BITS_PER_UNIT; - return MAX (factor, type_align); + if (TREE_CODE (target) == COMPONENT_REF) + target_align = DECL_ALIGN (TREE_OPERAND (target, 1)) / BITS_PER_UNIT; + else + target_align = TYPE_ALIGN (TREE_TYPE (target)) / BITS_PER_UNIT; + return MAX (factor, target_align); } /* Return an object on the placeholder list that matches EXP, a diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 99035b4..57c2eda 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-03-08 Eric Botcazou <ebotcazou@act-europe.fr> + + * gcc.c-torture/execute/20040308-1.c: New test. + 2004-03-07 Roger Sayle <roger@eyesopen.com> * gcc.c-torture/execute/20040307-1.c: New test case. diff --git a/gcc/testsuite/gcc.c-torture/execute/20040308-1.c b/gcc/testsuite/gcc.c-torture/execute/20040308-1.c new file mode 100644 index 0000000..4c63535 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20040308-1.c @@ -0,0 +1,21 @@ +/* This used to fail on SPARC with an unaligned memory access. */ + +void foo(int n) +{ + struct S { + int i[n]; + unsigned int b:1; + int i2; + } __attribute__ ((packed)) __attribute__ ((aligned (4))); + + struct S s; + + s.i2 = 0; +} + +int main(void) +{ + foo(4); + + return 0; +} |