summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authordrow <drow@138bc75d-0d04-0410-961f-82ee72b054a4>2008-02-23 15:45:03 +0000
committerdrow <drow@138bc75d-0d04-0410-961f-82ee72b054a4>2008-02-23 15:45:03 +0000
commit05b481dffd9c3b7b44b7181d16f248b04a81ab41 (patch)
tree84e9fb8c32865e229b5d07b01784d8d73cbd761c /gcc
parent78624f54126e08b382f81829ee419c20e884254d (diff)
downloadgcc-05b481dffd9c3b7b44b7181d16f248b04a81ab41.tar.gz
* expmed.c (extract_bit_field): Always use adjust_address for MEM.
* gcc.c-torture/execute/20080222-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132573 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/expmed.c19
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20080222-1.c22
4 files changed, 38 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9a90b880a2e..f33f1d352d4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-23 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * expmed.c (extract_bit_field): Always use adjust_address for MEM.
+
2008-02-23 Uros Bizjak <ubizjak@gmail.com>
PR target/22076
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 09a58dedba2..04071d375ed 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -1339,18 +1339,15 @@ extract_bit_field_1 (rtx str_rtx, unsigned HOST_WIDE_INT bitsize,
|| (offset * BITS_PER_UNIT % bitsize == 0
&& MEM_ALIGN (op0) % bitsize == 0)))))
{
- if (mode1 != GET_MODE (op0))
+ if (MEM_P (op0))
+ op0 = adjust_address (op0, mode1, offset);
+ else if (mode1 != GET_MODE (op0))
{
- if (MEM_P (op0))
- op0 = adjust_address (op0, mode1, offset);
- else
- {
- rtx sub = simplify_gen_subreg (mode1, op0, GET_MODE (op0),
- byte_offset);
- if (sub == NULL)
- goto no_subreg_mode_swap;
- op0 = sub;
- }
+ rtx sub = simplify_gen_subreg (mode1, op0, GET_MODE (op0),
+ byte_offset);
+ if (sub == NULL)
+ goto no_subreg_mode_swap;
+ op0 = sub;
}
if (mode1 != mode)
return convert_to_mode (tmode, op0, unsignedp);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 21776c423cd..b111ef4da71 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-23 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * gcc.c-torture/execute/20080222-1.c: New test.
+
2008-02-23 Uros Bizjak <ubizjak@gmail.com>
PR target/22076
diff --git a/gcc/testsuite/gcc.c-torture/execute/20080222-1.c b/gcc/testsuite/gcc.c-torture/execute/20080222-1.c
new file mode 100644
index 00000000000..6db83ccdf90
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20080222-1.c
@@ -0,0 +1,22 @@
+extern void abort (void);
+
+struct container
+{
+ unsigned char data[1];
+};
+
+unsigned char space[6] = {1, 2, 3, 4, 5, 6};
+
+int
+foo (struct container *p)
+{
+ return p->data[4];
+}
+
+int
+main ()
+{
+ if (foo ((struct container *) space) != 5)
+ abort ();
+ return 0;
+}