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]

Re: purge_addressof bug



  In message <19980930145945.A19705@dot.cygnus.com>you write:
  > The following program is mis-compiled on x86 by c++ with -O3. 
  > 
  > Due to some difference I didn't care to ponder, it does not
  > fail compiled as c.  Not that it matters much, since the
  > problem exposed below is still a problem.
  > 
  > ---------
  > typedef struct st { unsigned char a, b, c, d; } st;
  > void testme(int, int, int);
  > 
  > static void stupid_func(st s) { testme(s.a, s.b, s.c); }
  > 
  > main()
  > {
  >         st s;
  >         s.a = s.b = s.c = 216;
  >         stupid_func(s);
  >         return 0;
  > }    
  > 
  > void testme(int a, int b, int c)
  > {
  >   if (a != 216 && b != 216 && c != 216)
  >     abort();
  > }
  > ---------
  > 
  > The root problem is that purge_addressof_1 turns
  > 
  >    (insn 43 16 45 (set (mem/s:QI (addressof:SI (reg:SI 23) 22) 0)
  >            (reg:QI 32)) 64 {movqi+1} (nil)
  >        (nil))
  > 
  > into 
  > 
  >    (insn 43 16 45 (set (subreg:QI (reg:SI 23) 0)
  >            (reg:QI 32)) 64 {movqi+1} (nil)
  >        (nil))
  > 
  > which is incorrect -- a strict_low_part is required.
  > 
  > The following patch changes things up to use proper bit insertion
  > and extraction routines.  As a bonus, we can now avoid dropping
  > the register to memory in this case on big-endian machines.
  > 
  > 
  > r~
  > 
  > 
  > 	* function.c (purge_addressof_1): Use bitfield manipulation
  > 	routines to handle mem mode < reg mode.
Seems reasonable to me.  Can you make sure to add the test to the testsuite
too?

Thanks,
jeff


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