]> gcc.gnu.org Git - gcc.git/commitdiff
combine.c (make_extraction): Correct offset computation.
authorAdrian Straetling <straetling@de.ibm.com>
Wed, 12 Oct 2005 20:30:46 +0000 (20:30 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 12 Oct 2005 20:30:46 +0000 (20:30 +0000)
* combine.c (make_extraction): Correct offset computation.
* gcc.c-torture/execute/20051012-1.c: New test.

From-SVN: r105330

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

index 93da68720465b3a0ffc8b00938c68b738be2a01b..f2b9db354b67c72712d30d2c985a27be9fa719ae 100644 (file)
@@ -1,3 +1,7 @@
+2005-10-12  Adrian Straetling <straetling@de.ibm.com>
+
+       * combine.c (make_extraction): Correct offset computation.
+
 2005-10-12  Hans-Peter Nilsson  <hp@axis.com>
 
        * config/cris/t-linux (LIMITS_H_TEST): Define.
index 3be34e4b44d5be6288a52b98531d9a2a68c89d16..ff10663a147ffda105e8da8463c1c9ab80f60303 100644 (file)
@@ -6512,11 +6512,12 @@ make_extraction (enum machine_mode mode, rtx inner, HOST_WIDE_INT pos,
        offset -= GET_MODE_SIZE (is_mode) - GET_MODE_SIZE (inner_mode);
 
       /* If this is a constant position, we can move to the desired byte.
-        Be careful not to go beyond the original object. */
+        Be careful not to go beyond the original object and maintain the
+        natural alignment of the memory.  */ 
       if (pos_rtx == 0)
        {
          enum machine_mode bfmode = smallest_mode_for_size (len, MODE_INT);
-         offset += pos / GET_MODE_BITSIZE (bfmode);
+         offset += (pos / GET_MODE_BITSIZE (bfmode)) * GET_MODE_SIZE (bfmode);
          pos %= GET_MODE_BITSIZE (bfmode);
        }
 
index 7abf169d21743b9bc577a6eee48d902784e84da7..be34d210880a99eb59a1758b9b55aa8d91c205f8 100644 (file)
@@ -1,3 +1,7 @@
+2005-10-12  Adrian Straetling <straetling@de.ibm.com>
+
+       * gcc.c-torture/execute/20051012-1.c: New test.
+
 2005-10-12  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/18082
diff --git a/gcc/testsuite/gcc.c-torture/execute/20051012-1.c b/gcc/testsuite/gcc.c-torture/execute/20051012-1.c
new file mode 100644 (file)
index 0000000..f12f429
--- /dev/null
@@ -0,0 +1,24 @@
+extern void abort (void);
+
+struct type 
+{
+  int *a;
+  
+  int b:16;
+  unsigned int p:9;
+} t;
+
+unsigned int 
+foo ()
+{
+  return t.p;
+}
+
+int 
+main (void)
+{
+  t.p = 8;
+  if (foo (t) != 8)
+    abort ();
+  return 0;
+}
This page took 0.115079 seconds and 5 git commands to generate.