aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@act-europe.fr>2004-03-08 07:48:51 +0100
committerEric Botcazou <ebotcazou@gcc.gnu.org>2004-03-08 06:48:51 +0000
commitd50a16c4335e68f36982ab6e2de8744d6bcd101d (patch)
treefa9e3e9dcafa91608c9e55c39fab6204b9942a22 /gcc
parentb1917422afdc729bafd42f01433fd4d0e2cdf760 (diff)
downloadgcc-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/ChangeLog7
-rw-r--r--gcc/expr.c23
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20040308-1.c21
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.
diff --git a/gcc/expr.c b/gcc/expr.c
index 9bd2740..d526750 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -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;
+}