expmed.c (extract_bit_field): Always use adjust_address for MEM.
authorDaniel Jacobowitz <dan@codesourcery.com>
Sat, 23 Feb 2008 15:45:03 +0000 (15:45 +0000)
committerDaniel Jacobowitz <drow@gcc.gnu.org>
Sat, 23 Feb 2008 15:45:03 +0000 (15:45 +0000)
* expmed.c (extract_bit_field): Always use adjust_address for MEM.

* gcc.c-torture/execute/20080222-1.c: New test.

From-SVN: r132573

gcc/ChangeLog
gcc/expmed.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20080222-1.c [new file with mode: 0644]

index 9a90b880a2ed7e9a5abc1c440587e6b6fc3e9317..f33f1d352d489e63b6d84900c9f543d7e7f88ace 100644 (file)
@@ -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
index 09a58dedba20a8625c16051ab49e3f177bc2a197..04071d375ed9a81700084ad034eeb0809f3889c8 100644 (file)
@@ -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);
index 21776c423cdca99a81cfc44fe430af50544b44db..b111ef4da71e89e1a89f8c4bedca75e2f1c8ee9e 100644 (file)
@@ -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 (file)
index 0000000..6db83cc
--- /dev/null
@@ -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;
+}