This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: Fix bug in combine
- From: Adrian Straetling <straetling at de dot ibm dot com>
- To: Ian Lance Taylor <ian at airs dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, dalej at apple dot com, "Weigand, Ulrich" <uweigand at de dot ibm dot com>
- Date: Wed, 12 Oct 2005 18:47:40 +0200
- Subject: Re: Patch: Fix bug in combine
- References: <77bffcc2f9ed331b38df125753838ac0@apple.com> <m3zmr4tsq6.fsf@gossamer.airs.com> <0e767d4868bdcf09f9dc2147d1ffa80d@apple.com> <m3acj4tpm8.fsf@gossamer.airs.com> <434C3016.4040502@de.ibm.com> <m33bn7wvvn.fsf@gossamer.airs.com>
On Tue, Oct 11, 2005 at 03:07:24PM -0700, Ian Lance Taylor wrote:
> Adrian Straetling <straetling@de.ibm.com> writes:
>
> > 2005-10-11 Adrian Straetling <straetling@de.ibm.com>
> >
> > * combine.c (make_extraction): Correct offset computation.
>
> This is OK if bootstrap and testing passes.
bootstrapped and regtested on s390,s390x,i686 with no regression.
This patch also includes a testcase that triggers on s390 without the
combine fix.
Bye,
Adrian
2005-10-12 Adrian Straetling <straetling@de.ibm.com>
* combine.c (make_extraction): Correct offset computation.
* gcc/testsuite/gcc.dg/20051012-1.c: New.
Index: gcc/combine.c
===================================================================
*** gcc/combine.c.orig 2005-10-12 16:11:09.384003958 +0200
--- gcc/combine.c 2005-10-12 16:15:42.464003958 +0200
*************** make_extraction (enum machine_mode mode,
*** 6485,6495 ****
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. */
if (pos_rtx == 0)
{
enum machine_mode bfmode = smallest_mode_for_size (len, MODE_INT);
! offset += pos / GET_MODE_BITSIZE (bfmode);
pos %= GET_MODE_BITSIZE (bfmode);
}
--- 6485,6496 ----
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 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)) * GET_MODE_SIZE (bfmode);
pos %= GET_MODE_BITSIZE (bfmode);
}
Index: gcc/testsuite/gcc.dg/20051012-1.c
===================================================================
*** /dev/null 1970-01-01 00:00:00.000000000 +0000
--- gcc/testsuite/gcc.dg/20051012-1.c 2005-10-12 16:20:18.194003958 +0200
***************
*** 0 ****
--- 1,23 ----
+ /* { dg-do run { target i?86-*-linux* x86_64-*-linux* ia64-*-linux* alpha*-*-linux* powerpc*-*-linux* s390*-*-linux* sparc*-*-linux* i?86-*-darwin* powerpc-*-darwin*} } */
+ /* { dg-options "-O2" } */
+
+ struct type
+ {
+ int *a;
+
+ int b:16;
+ unsigned int p:9;
+ } t;
+
+ unsigned int
+ foo ()
+ {
+ return t.p;
+ }
+
+ int
+ main (void)
+ {
+ t.p = 8;
+ return foo(t) != 8;
+ }