OSDN Git Service

* expmed.c (extract_bit_field): Always use adjust_address for MEM.
authordrow <drow@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 23 Feb 2008 15:45:03 +0000 (15:45 +0000)
committerdrow <drow@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 23 Feb 2008 15:45:03 +0000 (15:45 +0000)
* 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

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

index 9a90b88..f33f1d3 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 09a58de..04071d3 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 21776c4..b111ef4 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;
+}