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: replace_regs fix (and cleanup)


Jan Hubicka <jh@suse.cz> writes:

> Hi,
> while debugging the last PPC failure, I've noticed that we do have
> bug in the SUBREG combining code in most places.  We can't simple
> add the SUBREG_BYTEs, as on little endian machines, the paradoxical
> subreg should have negative offset, but have 0.  This produced the
> weird PPC subreg and in fact I've fixed the bug accidentally by
> promoting use of simplify_subreg everywhere.
> 
> This patch fixes the hopefully last occurence of subreg combining
> code.
> 
> I386 bootstrap in progress, OK assuming it passes?
> Honza

That makes much more sense.  This is OK (although it would probably be
a good idea to test it on a RISC platform too).

> Thu May 24 19:49:49 CEST 2001  Jan Hubicka  <jh@suse.cz>
> 
> 	* rtlanal.c (replace_regs):  Use simplify_gen_subreg
> 
> *** rtlanal.c	Mon May 21 14:29:59 2001
> --- rtlanal.c2	Thu May 24 19:30:03 2001
> *************** replace_regs (x, reg_map, nregs, replace
> *** 2259,2297 ****
>   	{
>   	  rtx map_val = reg_map[REGNO (SUBREG_REG (x))];
>   	  rtx map_inner = SUBREG_REG (map_val);
> ! 
> ! 	  if (GET_MODE (x) == GET_MODE (map_inner))
> ! 	    return map_inner;
> ! 	  else
> ! 	    {
> ! 	      int final_offset = SUBREG_BYTE (x) + SUBREG_BYTE (map_val);
> ! 
> ! 	      /* When working with REG SUBREGs the rule is that the byte
> ! 		 offset must be a multiple of the SUBREG's mode.  */
> ! 	      final_offset = (final_offset / GET_MODE_SIZE (GET_MODE (x)));
> ! 	      final_offset = (final_offset * GET_MODE_SIZE (GET_MODE (x)));
> ! 
> ! 	      /* We cannot call gen_rtx here since we may be linked with
> ! 		 genattrtab.c.  */
> ! 	      /* Let's try clobbering the incoming SUBREG and see
> ! 		 if this is really safe.  */
> ! 	      SUBREG_REG (x) = map_inner;
> ! 	      SUBREG_BYTE (x) = final_offset;
> ! 	      return x;
> ! #if 0
> ! 	      rtx new = rtx_alloc (SUBREG);
> ! 	      int final_offset = SUBREG_BYTE (x) + SUBREG_BYTE (map_val);
> ! 
> ! 	      /* When working with REG SUBREGs the rule is that the byte
> ! 		 offset must be a multiple of the SUBREG's mode.  */
> ! 	      final_offset = (final_offset / GET_MODE_SIZE (GET_MODE (x)));
> ! 	      final_offset = (final_offset * GET_MODE_SIZE (GET_MODE (x)));
> ! 
> ! 	      PUT_MODE (new, GET_MODE (x));
> ! 	      SUBREG_REG (new) = map_inner;
> ! 	      SUBREG_BYTE (new) = final_offset;
> ! #endif
> ! 	    }
>   	}
>         break;
>   
> --- 2259,2267 ----
>   	{
>   	  rtx map_val = reg_map[REGNO (SUBREG_REG (x))];
>   	  rtx map_inner = SUBREG_REG (map_val);
> ! 	  return simplify_gen_subreg (GET_MODE (x), map_val,
> ! 				      GET_MODE (SUBREG_REG (x)), 
> ! 				      SUBREG_BYTE (x));
>   	}
>         break;
>   

-- 
- Geoffrey Keating <geoffk@geoffk.org>


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