This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: Fix bug in combine


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;
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]