public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* cleanup alter_subreg; fix simplify_subreg
@ 2001-11-01  5:45 Jan Hubicka
  2001-11-03 23:30 ` Richard Henderson
                   ` (7 more replies)
  0 siblings, 8 replies; 19+ messages in thread
From: Jan Hubicka @ 2001-11-01  5:45 UTC (permalink / raw)
  To: gcc-patches, patches, rth


Hi,
this patch avoid replacing of SUBREG by REG at place in alter_subreg
and cleans it up by calling simplify_subreg instead.

This fixes several problems in my future patch and makes everything
cleaner.

Bootstrapped/regtested i686
Honza

Sun Nov 11 19:53:52 CET 2001  Jan Hubicka  <jh@suse.cz>

	* dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
	* final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
	(final_scan_insn): Update call of alter_subreg.
	(cleanup_subreg_operands): Likewise.
	(alter_subreg): Rewrite using simplify_subreg.
	(output_address, output_operand): Update call of alter_subreg.
	* output.h (alter_subreg): Update prototype.
	* sdbout.c (sdbout_symbol): Update call of alter_subreg.
	* simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.

*** ../../e2/egcs/gcc/dbxout.c	Sat Nov 10 22:32:27 2001
--- dbxout.c	Sun Nov 11 18:22:24 2001
*************** dbxout_symbol_location (decl, type, suff
*** 2107,2113 ****
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (home);
      }
    if (GET_CODE (home) == REG)
      {
--- 2107,2113 ----
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (&home);
      }
    if (GET_CODE (home) == REG)
      {
*** ../../e2/egcs/gcc/final.c	Thu Nov  8 16:06:56 2001
--- final.c	Sun Nov 11 18:53:22 2001
*************** static void profile_after_prologue PARAM
*** 242,248 ****
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
--- 243,249 ----
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx *));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
*************** final_scan_insn (insn, file, optimize, p
*** 2631,2645 ****
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
--- 2632,2646 ----
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (&SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (&XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (&XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
*************** cleanup_subreg_operands (insn)
*** 3001,3021 ****
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (*recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (*recog_data.dup_loc[i]);
      }
  }
  
--- 3002,3022 ----
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand_loc[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand_loc[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (recog_data.dup_loc[i]);
      }
  }
  
*************** cleanup_subreg_operands (insn)
*** 3023,3088 ****
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (x)
!      rtx x;
  {
    rtx y = SUBREG_REG (x);
  
!   if (GET_CODE (y) == SUBREG)
!     y = alter_subreg (y);
! 
!   /* If reload is operating, we may be replacing inside this SUBREG.
!      Check for that and make a new one if so.  */
!   if (reload_in_progress && find_replacement (&SUBREG_REG (x)) != 0)
!     x = copy_rtx (x);
! 
!   if (GET_CODE (y) == REG)
!     {
!       int regno = subreg_hard_regno (x, 1);
! 
!       PUT_CODE (x, REG);
!       REGNO (x) = regno;
!       ORIGINAL_REGNO (x) = ORIGINAL_REGNO (y);
!       /* This field has a different meaning for REGs and SUBREGs.  Make sure
! 	 to clear it!  */
!       x->used = 0;
!     }
!   else if (GET_CODE (y) == MEM)
      {
!       HOST_WIDE_INT offset = SUBREG_BYTE (x);
! 
!       /* Catch these instead of generating incorrect code.  */
!       if ((offset % GET_MODE_SIZE (GET_MODE (x))) != 0)
! 	abort ();
! 
!       PUT_CODE (x, MEM);
!       MEM_COPY_ATTRIBUTES (x, y);
!       XEXP (x, 0) = plus_constant (XEXP (y, 0), offset);
      }
! 
!   return x;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (x)
!      rtx x;
  {
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (x);
  
      default:
        break;
--- 3024,3070 ----
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    rtx y = SUBREG_REG (x);
  
!   /* simplify_subreg does not remove subreg from volatile references.
!      We are required to.  */
!   if (GET_CODE (y) == MEM)
!     *xp = adjust_address (y, GET_MODE (x), SUBREG_BYTE (x));
!   else
      {
!       rtx new = simplify_subreg (GET_MODE (x), y, GET_MODE (y), SUBREG_BYTE (x));
!       if (!new)
! 	debug_rtx (x);
!       *xp = new;
      }
!   return *xp;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (xp);
  
      default:
        break;
*************** output_operand (x, code)
*** 3621,3627 ****
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
--- 3609,3615 ----
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (&x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
*************** void
*** 3640,3646 ****
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
--- 3628,3634 ----
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (&x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
*** ../../e2/egcs/gcc/output.h	Thu Nov  8 16:24:14 2001
--- output.h	Sun Nov 11 18:22:40 2001
*************** extern rtx final_scan_insn	PARAMS ((rtx,
*** 77,83 ****
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
--- 77,83 ----
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx *));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
*** ../../e2/egcs/gcc/sdbout.c	Sun Nov  4 21:19:24 2001
--- sdbout.c	Sun Nov 11 18:21:03 2001
*************** sdbout_symbol (decl, local)
*** 809,815 ****
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
--- 809,815 ----
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (&DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
*** ../../e2/egcs/gcc/simplify-rtx.c	Sun Nov  4 21:19:24 2001
--- simplify-rtx.c	Sun Nov 11 18:33:51 2001
*************** simplify_subreg (outermode, op, innermod
*** 2587,2593 ****
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	return gen_rtx_REG (outermode, final_regno);
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are
--- 2587,2604 ----
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	{
! 	  rtx x = gen_rtx_REG (outermode, final_regno);
! 
! 	  /* Propagate original regno.  We don't have any way to specify
! 	     the offset inside orignal regno, so do so only for lowpart.
! 	     The information is used only by alias analysis that can not
! 	     grog partial register anyway.  */
! 
! 	  if (subreg_lowpart_offset (outermode, innermode) == byte)
! 	    ORIGINAL_REGNO (x) = ORIGINAL_REGNO (op);
! 	  return x;
! 	}
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
  2001-11-01  5:45 cleanup alter_subreg; fix simplify_subreg Jan Hubicka
@ 2001-11-03 23:30 ` Richard Henderson
  2001-11-13  4:26   ` Richard Henderson
  2001-11-13 15:03   ` Richard Henderson
  2001-11-12 12:11 ` Jan Hubicka
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 19+ messages in thread
From: Richard Henderson @ 2001-11-03 23:30 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches, patches

On Sun, Nov 11, 2001 at 05:47:05PM +0100, Jan Hubicka wrote:
> 	* dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
> 	* final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
> 	(final_scan_insn): Update call of alter_subreg.
> 	(cleanup_subreg_operands): Likewise.
> 	(alter_subreg): Rewrite using simplify_subreg.
> 	(output_address, output_operand): Update call of alter_subreg.
> 	* output.h (alter_subreg): Update prototype.
> 	* sdbout.c (sdbout_symbol): Update call of alter_subreg.
> 	* simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.

Ok, except, 

> !       if (!new)
> ! 	debug_rtx (x);

You left this in.


r~

^ permalink raw reply	[flat|nested] 19+ messages in thread

* cleanup alter_subreg; fix simplify_subreg
  2001-11-01  5:45 cleanup alter_subreg; fix simplify_subreg Jan Hubicka
  2001-11-03 23:30 ` Richard Henderson
@ 2001-11-12 12:11 ` Jan Hubicka
  2001-11-13  4:26 ` Jan Hubicka
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Jan Hubicka @ 2001-11-12 12:11 UTC (permalink / raw)
  To: gcc-patches, patches, rth

Hi,
this patch avoid replacing of SUBREG by REG at place in alter_subreg
and cleans it up by calling simplify_subreg instead.

This fixes several problems in my future patch and makes everything
cleaner.

Bootstrapped/regtested i686
Honza

Sun Nov 11 19:53:52 CET 2001  Jan Hubicka  <jh@suse.cz>

	* dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
	* final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
	(final_scan_insn): Update call of alter_subreg.
	(cleanup_subreg_operands): Likewise.
	(alter_subreg): Rewrite using simplify_subreg.
	(output_address, output_operand): Update call of alter_subreg.
	* output.h (alter_subreg): Update prototype.
	* sdbout.c (sdbout_symbol): Update call of alter_subreg.
	* simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.

*** ../../e2/egcs/gcc/dbxout.c	Sat Nov 10 22:32:27 2001
--- dbxout.c	Sun Nov 11 18:22:24 2001
*************** dbxout_symbol_location (decl, type, suff
*** 2107,2113 ****
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (home);
      }
    if (GET_CODE (home) == REG)
      {
--- 2107,2113 ----
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (&home);
      }
    if (GET_CODE (home) == REG)
      {
*** ../../e2/egcs/gcc/final.c	Thu Nov  8 16:06:56 2001
--- final.c	Sun Nov 11 18:53:22 2001
*************** static void profile_after_prologue PARAM
*** 242,248 ****
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
--- 243,249 ----
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx *));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
*************** final_scan_insn (insn, file, optimize, p
*** 2631,2645 ****
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
--- 2632,2646 ----
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (&SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (&XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (&XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
*************** cleanup_subreg_operands (insn)
*** 3001,3021 ****
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (*recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (*recog_data.dup_loc[i]);
      }
  }
  
--- 3002,3022 ----
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand_loc[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand_loc[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (recog_data.dup_loc[i]);
      }
  }
  
*************** cleanup_subreg_operands (insn)
*** 3023,3088 ****
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (x)
!      rtx x;
  {
    rtx y = SUBREG_REG (x);
  
!   if (GET_CODE (y) == SUBREG)
!     y = alter_subreg (y);
! 
!   /* If reload is operating, we may be replacing inside this SUBREG.
!      Check for that and make a new one if so.  */
!   if (reload_in_progress && find_replacement (&SUBREG_REG (x)) != 0)
!     x = copy_rtx (x);
! 
!   if (GET_CODE (y) == REG)
!     {
!       int regno = subreg_hard_regno (x, 1);
! 
!       PUT_CODE (x, REG);
!       REGNO (x) = regno;
!       ORIGINAL_REGNO (x) = ORIGINAL_REGNO (y);
!       /* This field has a different meaning for REGs and SUBREGs.  Make sure
! 	 to clear it!  */
!       x->used = 0;
!     }
!   else if (GET_CODE (y) == MEM)
      {
!       HOST_WIDE_INT offset = SUBREG_BYTE (x);
! 
!       /* Catch these instead of generating incorrect code.  */
!       if ((offset % GET_MODE_SIZE (GET_MODE (x))) != 0)
! 	abort ();
! 
!       PUT_CODE (x, MEM);
!       MEM_COPY_ATTRIBUTES (x, y);
!       XEXP (x, 0) = plus_constant (XEXP (y, 0), offset);
      }
! 
!   return x;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (x)
!      rtx x;
  {
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (x);
  
      default:
        break;
--- 3024,3070 ----
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    rtx y = SUBREG_REG (x);
  
!   /* simplify_subreg does not remove subreg from volatile references.
!      We are required to.  */
!   if (GET_CODE (y) == MEM)
!     *xp = adjust_address (y, GET_MODE (x), SUBREG_BYTE (x));
!   else
      {
!       rtx new = simplify_subreg (GET_MODE (x), y, GET_MODE (y), SUBREG_BYTE (x));
!       if (!new)
! 	debug_rtx (x);
!       *xp = new;
      }
!   return *xp;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (xp);
  
      default:
        break;
*************** output_operand (x, code)
*** 3621,3627 ****
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
--- 3609,3615 ----
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (&x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
*************** void
*** 3640,3646 ****
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
--- 3628,3634 ----
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (&x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
*** ../../e2/egcs/gcc/output.h	Thu Nov  8 16:24:14 2001
--- output.h	Sun Nov 11 18:22:40 2001
*************** extern rtx final_scan_insn	PARAMS ((rtx,
*** 77,83 ****
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
--- 77,83 ----
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx *));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
*** ../../e2/egcs/gcc/sdbout.c	Sun Nov  4 21:19:24 2001
--- sdbout.c	Sun Nov 11 18:21:03 2001
*************** sdbout_symbol (decl, local)
*** 809,815 ****
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
--- 809,815 ----
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (&DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
*** ../../e2/egcs/gcc/simplify-rtx.c	Sun Nov  4 21:19:24 2001
--- simplify-rtx.c	Sun Nov 11 18:33:51 2001
*************** simplify_subreg (outermode, op, innermod
*** 2587,2593 ****
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	return gen_rtx_REG (outermode, final_regno);
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are
--- 2587,2604 ----
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	{
! 	  rtx x = gen_rtx_REG (outermode, final_regno);
! 
! 	  /* Propagate original regno.  We don't have any way to specify
! 	     the offset inside orignal regno, so do so only for lowpart.
! 	     The information is used only by alias analysis that can not
! 	     grog partial register anyway.  */
! 
! 	  if (subreg_lowpart_offset (outermode, innermode) == byte)
! 	    ORIGINAL_REGNO (x) = ORIGINAL_REGNO (op);
! 	  return x;
! 	}
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
  2001-11-03 23:30 ` Richard Henderson
@ 2001-11-13  4:26   ` Richard Henderson
  2001-11-13 15:03   ` Richard Henderson
  1 sibling, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2001-11-13  4:26 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches, patches

On Sun, Nov 11, 2001 at 05:47:05PM +0100, Jan Hubicka wrote:
> 	* dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
> 	* final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
> 	(final_scan_insn): Update call of alter_subreg.
> 	(cleanup_subreg_operands): Likewise.
> 	(alter_subreg): Rewrite using simplify_subreg.
> 	(output_address, output_operand): Update call of alter_subreg.
> 	* output.h (alter_subreg): Update prototype.
> 	* sdbout.c (sdbout_symbol): Update call of alter_subreg.
> 	* simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.

Ok, except, 

> !       if (!new)
> ! 	debug_rtx (x);

You left this in.


r~

^ permalink raw reply	[flat|nested] 19+ messages in thread

* cleanup alter_subreg; fix simplify_subreg
  2001-11-01  5:45 cleanup alter_subreg; fix simplify_subreg Jan Hubicka
  2001-11-03 23:30 ` Richard Henderson
  2001-11-12 12:11 ` Jan Hubicka
@ 2001-11-13  4:26 ` Jan Hubicka
  2001-11-13  5:27 ` Jan Hubicka
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Jan Hubicka @ 2001-11-13  4:26 UTC (permalink / raw)
  To: gcc-patches, patches, rth


Hi,
this patch avoid replacing of SUBREG by REG at place in alter_subreg
and cleans it up by calling simplify_subreg instead.

This fixes several problems in my future patch and makes everything
cleaner.

Bootstrapped/regtested i686
Honza

Sun Nov 11 19:53:52 CET 2001  Jan Hubicka  <jh@suse.cz>

	* dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
	* final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
	(final_scan_insn): Update call of alter_subreg.
	(cleanup_subreg_operands): Likewise.
	(alter_subreg): Rewrite using simplify_subreg.
	(output_address, output_operand): Update call of alter_subreg.
	* output.h (alter_subreg): Update prototype.
	* sdbout.c (sdbout_symbol): Update call of alter_subreg.
	* simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.

*** ../../e2/egcs/gcc/dbxout.c	Sat Nov 10 22:32:27 2001
--- dbxout.c	Sun Nov 11 18:22:24 2001
*************** dbxout_symbol_location (decl, type, suff
*** 2107,2113 ****
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (home);
      }
    if (GET_CODE (home) == REG)
      {
--- 2107,2113 ----
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (&home);
      }
    if (GET_CODE (home) == REG)
      {
*** ../../e2/egcs/gcc/final.c	Thu Nov  8 16:06:56 2001
--- final.c	Sun Nov 11 18:53:22 2001
*************** static void profile_after_prologue PARAM
*** 242,248 ****
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
--- 243,249 ----
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx *));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
*************** final_scan_insn (insn, file, optimize, p
*** 2631,2645 ****
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
--- 2632,2646 ----
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (&SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (&XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (&XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
*************** cleanup_subreg_operands (insn)
*** 3001,3021 ****
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (*recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (*recog_data.dup_loc[i]);
      }
  }
  
--- 3002,3022 ----
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand_loc[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand_loc[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (recog_data.dup_loc[i]);
      }
  }
  
*************** cleanup_subreg_operands (insn)
*** 3023,3088 ****
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (x)
!      rtx x;
  {
    rtx y = SUBREG_REG (x);
  
!   if (GET_CODE (y) == SUBREG)
!     y = alter_subreg (y);
! 
!   /* If reload is operating, we may be replacing inside this SUBREG.
!      Check for that and make a new one if so.  */
!   if (reload_in_progress && find_replacement (&SUBREG_REG (x)) != 0)
!     x = copy_rtx (x);
! 
!   if (GET_CODE (y) == REG)
!     {
!       int regno = subreg_hard_regno (x, 1);
! 
!       PUT_CODE (x, REG);
!       REGNO (x) = regno;
!       ORIGINAL_REGNO (x) = ORIGINAL_REGNO (y);
!       /* This field has a different meaning for REGs and SUBREGs.  Make sure
! 	 to clear it!  */
!       x->used = 0;
!     }
!   else if (GET_CODE (y) == MEM)
      {
!       HOST_WIDE_INT offset = SUBREG_BYTE (x);
! 
!       /* Catch these instead of generating incorrect code.  */
!       if ((offset % GET_MODE_SIZE (GET_MODE (x))) != 0)
! 	abort ();
! 
!       PUT_CODE (x, MEM);
!       MEM_COPY_ATTRIBUTES (x, y);
!       XEXP (x, 0) = plus_constant (XEXP (y, 0), offset);
      }
! 
!   return x;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (x)
!      rtx x;
  {
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (x);
  
      default:
        break;
--- 3024,3070 ----
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    rtx y = SUBREG_REG (x);
  
!   /* simplify_subreg does not remove subreg from volatile references.
!      We are required to.  */
!   if (GET_CODE (y) == MEM)
!     *xp = adjust_address (y, GET_MODE (x), SUBREG_BYTE (x));
!   else
      {
!       rtx new = simplify_subreg (GET_MODE (x), y, GET_MODE (y), SUBREG_BYTE (x));
!       if (!new)
! 	debug_rtx (x);
!       *xp = new;
      }
!   return *xp;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (xp);
  
      default:
        break;
*************** output_operand (x, code)
*** 3621,3627 ****
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
--- 3609,3615 ----
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (&x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
*************** void
*** 3640,3646 ****
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
--- 3628,3634 ----
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (&x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
*** ../../e2/egcs/gcc/output.h	Thu Nov  8 16:24:14 2001
--- output.h	Sun Nov 11 18:22:40 2001
*************** extern rtx final_scan_insn	PARAMS ((rtx,
*** 77,83 ****
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
--- 77,83 ----
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx *));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
*** ../../e2/egcs/gcc/sdbout.c	Sun Nov  4 21:19:24 2001
--- sdbout.c	Sun Nov 11 18:21:03 2001
*************** sdbout_symbol (decl, local)
*** 809,815 ****
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
--- 809,815 ----
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (&DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
*** ../../e2/egcs/gcc/simplify-rtx.c	Sun Nov  4 21:19:24 2001
--- simplify-rtx.c	Sun Nov 11 18:33:51 2001
*************** simplify_subreg (outermode, op, innermod
*** 2587,2593 ****
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	return gen_rtx_REG (outermode, final_regno);
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are
--- 2587,2604 ----
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	{
! 	  rtx x = gen_rtx_REG (outermode, final_regno);
! 
! 	  /* Propagate original regno.  We don't have any way to specify
! 	     the offset inside orignal regno, so do so only for lowpart.
! 	     The information is used only by alias analysis that can not
! 	     grog partial register anyway.  */
! 
! 	  if (subreg_lowpart_offset (outermode, innermode) == byte)
! 	    ORIGINAL_REGNO (x) = ORIGINAL_REGNO (op);
! 	  return x;
! 	}
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are

^ permalink raw reply	[flat|nested] 19+ messages in thread

* cleanup alter_subreg; fix simplify_subreg
  2001-11-01  5:45 cleanup alter_subreg; fix simplify_subreg Jan Hubicka
                   ` (2 preceding siblings ...)
  2001-11-13  4:26 ` Jan Hubicka
@ 2001-11-13  5:27 ` Jan Hubicka
  2001-11-13 13:40 ` Jan Hubicka
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Jan Hubicka @ 2001-11-13  5:27 UTC (permalink / raw)
  To: gcc-patches, patches, rth

Hi,
this patch avoid replacing of SUBREG by REG at place in alter_subreg
and cleans it up by calling simplify_subreg instead.

This fixes several problems in my future patch and makes everything
cleaner.

Bootstrapped/regtested i686
Honza

Sun Nov 11 19:53:52 CET 2001  Jan Hubicka  <jh@suse.cz>

	* dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
	* final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
	(final_scan_insn): Update call of alter_subreg.
	(cleanup_subreg_operands): Likewise.
	(alter_subreg): Rewrite using simplify_subreg.
	(output_address, output_operand): Update call of alter_subreg.
	* output.h (alter_subreg): Update prototype.
	* sdbout.c (sdbout_symbol): Update call of alter_subreg.
	* simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.

*** ../../e2/egcs/gcc/dbxout.c	Sat Nov 10 22:32:27 2001
--- dbxout.c	Sun Nov 11 18:22:24 2001
*************** dbxout_symbol_location (decl, type, suff
*** 2107,2113 ****
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (home);
      }
    if (GET_CODE (home) == REG)
      {
--- 2107,2113 ----
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (&home);
      }
    if (GET_CODE (home) == REG)
      {
*** ../../e2/egcs/gcc/final.c	Thu Nov  8 16:06:56 2001
--- final.c	Sun Nov 11 18:53:22 2001
*************** static void profile_after_prologue PARAM
*** 242,248 ****
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
--- 243,249 ----
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx *));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
*************** final_scan_insn (insn, file, optimize, p
*** 2631,2645 ****
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
--- 2632,2646 ----
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (&SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (&XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (&XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
*************** cleanup_subreg_operands (insn)
*** 3001,3021 ****
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (*recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (*recog_data.dup_loc[i]);
      }
  }
  
--- 3002,3022 ----
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand_loc[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand_loc[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (recog_data.dup_loc[i]);
      }
  }
  
*************** cleanup_subreg_operands (insn)
*** 3023,3088 ****
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (x)
!      rtx x;
  {
    rtx y = SUBREG_REG (x);
  
!   if (GET_CODE (y) == SUBREG)
!     y = alter_subreg (y);
! 
!   /* If reload is operating, we may be replacing inside this SUBREG.
!      Check for that and make a new one if so.  */
!   if (reload_in_progress && find_replacement (&SUBREG_REG (x)) != 0)
!     x = copy_rtx (x);
! 
!   if (GET_CODE (y) == REG)
!     {
!       int regno = subreg_hard_regno (x, 1);
! 
!       PUT_CODE (x, REG);
!       REGNO (x) = regno;
!       ORIGINAL_REGNO (x) = ORIGINAL_REGNO (y);
!       /* This field has a different meaning for REGs and SUBREGs.  Make sure
! 	 to clear it!  */
!       x->used = 0;
!     }
!   else if (GET_CODE (y) == MEM)
      {
!       HOST_WIDE_INT offset = SUBREG_BYTE (x);
! 
!       /* Catch these instead of generating incorrect code.  */
!       if ((offset % GET_MODE_SIZE (GET_MODE (x))) != 0)
! 	abort ();
! 
!       PUT_CODE (x, MEM);
!       MEM_COPY_ATTRIBUTES (x, y);
!       XEXP (x, 0) = plus_constant (XEXP (y, 0), offset);
      }
! 
!   return x;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (x)
!      rtx x;
  {
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (x);
  
      default:
        break;
--- 3024,3070 ----
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    rtx y = SUBREG_REG (x);
  
!   /* simplify_subreg does not remove subreg from volatile references.
!      We are required to.  */
!   if (GET_CODE (y) == MEM)
!     *xp = adjust_address (y, GET_MODE (x), SUBREG_BYTE (x));
!   else
      {
!       rtx new = simplify_subreg (GET_MODE (x), y, GET_MODE (y), SUBREG_BYTE (x));
!       if (!new)
! 	debug_rtx (x);
!       *xp = new;
      }
!   return *xp;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (xp);
  
      default:
        break;
*************** output_operand (x, code)
*** 3621,3627 ****
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
--- 3609,3615 ----
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (&x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
*************** void
*** 3640,3646 ****
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
--- 3628,3634 ----
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (&x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
*** ../../e2/egcs/gcc/output.h	Thu Nov  8 16:24:14 2001
--- output.h	Sun Nov 11 18:22:40 2001
*************** extern rtx final_scan_insn	PARAMS ((rtx,
*** 77,83 ****
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
--- 77,83 ----
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx *));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
*** ../../e2/egcs/gcc/sdbout.c	Sun Nov  4 21:19:24 2001
--- sdbout.c	Sun Nov 11 18:21:03 2001
*************** sdbout_symbol (decl, local)
*** 809,815 ****
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
--- 809,815 ----
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (&DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
*** ../../e2/egcs/gcc/simplify-rtx.c	Sun Nov  4 21:19:24 2001
--- simplify-rtx.c	Sun Nov 11 18:33:51 2001
*************** simplify_subreg (outermode, op, innermod
*** 2587,2593 ****
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	return gen_rtx_REG (outermode, final_regno);
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are
--- 2587,2604 ----
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	{
! 	  rtx x = gen_rtx_REG (outermode, final_regno);
! 
! 	  /* Propagate original regno.  We don't have any way to specify
! 	     the offset inside orignal regno, so do so only for lowpart.
! 	     The information is used only by alias analysis that can not
! 	     grog partial register anyway.  */
! 
! 	  if (subreg_lowpart_offset (outermode, innermode) == byte)
! 	    ORIGINAL_REGNO (x) = ORIGINAL_REGNO (op);
! 	  return x;
! 	}
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are

^ permalink raw reply	[flat|nested] 19+ messages in thread

* cleanup alter_subreg; fix simplify_subreg
  2001-11-01  5:45 cleanup alter_subreg; fix simplify_subreg Jan Hubicka
                   ` (3 preceding siblings ...)
  2001-11-13  5:27 ` Jan Hubicka
@ 2001-11-13 13:40 ` Jan Hubicka
  2001-11-13 15:03 ` Krister Walfridsson
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Jan Hubicka @ 2001-11-13 13:40 UTC (permalink / raw)
  To: gcc-patches, patches, rth

Hi,
this patch avoid replacing of SUBREG by REG at place in alter_subreg
and cleans it up by calling simplify_subreg instead.

This fixes several problems in my future patch and makes everything
cleaner.

Bootstrapped/regtested i686
Honza

Sun Nov 11 19:53:52 CET 2001  Jan Hubicka  <jh@suse.cz>

	* dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
	* final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
	(final_scan_insn): Update call of alter_subreg.
	(cleanup_subreg_operands): Likewise.
	(alter_subreg): Rewrite using simplify_subreg.
	(output_address, output_operand): Update call of alter_subreg.
	* output.h (alter_subreg): Update prototype.
	* sdbout.c (sdbout_symbol): Update call of alter_subreg.
	* simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.

*** ../../e2/egcs/gcc/dbxout.c	Sat Nov 10 22:32:27 2001
--- dbxout.c	Sun Nov 11 18:22:24 2001
*************** dbxout_symbol_location (decl, type, suff
*** 2107,2113 ****
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (home);
      }
    if (GET_CODE (home) == REG)
      {
--- 2107,2113 ----
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (&home);
      }
    if (GET_CODE (home) == REG)
      {
*** ../../e2/egcs/gcc/final.c	Thu Nov  8 16:06:56 2001
--- final.c	Sun Nov 11 18:53:22 2001
*************** static void profile_after_prologue PARAM
*** 242,248 ****
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
--- 243,249 ----
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx *));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
*************** final_scan_insn (insn, file, optimize, p
*** 2631,2645 ****
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
--- 2632,2646 ----
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (&SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (&XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (&XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
*************** cleanup_subreg_operands (insn)
*** 3001,3021 ****
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (*recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (*recog_data.dup_loc[i]);
      }
  }
  
--- 3002,3022 ----
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand_loc[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand_loc[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (recog_data.dup_loc[i]);
      }
  }
  
*************** cleanup_subreg_operands (insn)
*** 3023,3088 ****
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (x)
!      rtx x;
  {
    rtx y = SUBREG_REG (x);
  
!   if (GET_CODE (y) == SUBREG)
!     y = alter_subreg (y);
! 
!   /* If reload is operating, we may be replacing inside this SUBREG.
!      Check for that and make a new one if so.  */
!   if (reload_in_progress && find_replacement (&SUBREG_REG (x)) != 0)
!     x = copy_rtx (x);
! 
!   if (GET_CODE (y) == REG)
!     {
!       int regno = subreg_hard_regno (x, 1);
! 
!       PUT_CODE (x, REG);
!       REGNO (x) = regno;
!       ORIGINAL_REGNO (x) = ORIGINAL_REGNO (y);
!       /* This field has a different meaning for REGs and SUBREGs.  Make sure
! 	 to clear it!  */
!       x->used = 0;
!     }
!   else if (GET_CODE (y) == MEM)
      {
!       HOST_WIDE_INT offset = SUBREG_BYTE (x);
! 
!       /* Catch these instead of generating incorrect code.  */
!       if ((offset % GET_MODE_SIZE (GET_MODE (x))) != 0)
! 	abort ();
! 
!       PUT_CODE (x, MEM);
!       MEM_COPY_ATTRIBUTES (x, y);
!       XEXP (x, 0) = plus_constant (XEXP (y, 0), offset);
      }
! 
!   return x;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (x)
!      rtx x;
  {
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (x);
  
      default:
        break;
--- 3024,3070 ----
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    rtx y = SUBREG_REG (x);
  
!   /* simplify_subreg does not remove subreg from volatile references.
!      We are required to.  */
!   if (GET_CODE (y) == MEM)
!     *xp = adjust_address (y, GET_MODE (x), SUBREG_BYTE (x));
!   else
      {
!       rtx new = simplify_subreg (GET_MODE (x), y, GET_MODE (y), SUBREG_BYTE (x));
!       if (!new)
! 	debug_rtx (x);
!       *xp = new;
      }
!   return *xp;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (xp);
  
      default:
        break;
*************** output_operand (x, code)
*** 3621,3627 ****
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
--- 3609,3615 ----
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (&x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
*************** void
*** 3640,3646 ****
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
--- 3628,3634 ----
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (&x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
*** ../../e2/egcs/gcc/output.h	Thu Nov  8 16:24:14 2001
--- output.h	Sun Nov 11 18:22:40 2001
*************** extern rtx final_scan_insn	PARAMS ((rtx,
*** 77,83 ****
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
--- 77,83 ----
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx *));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
*** ../../e2/egcs/gcc/sdbout.c	Sun Nov  4 21:19:24 2001
--- sdbout.c	Sun Nov 11 18:21:03 2001
*************** sdbout_symbol (decl, local)
*** 809,815 ****
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
--- 809,815 ----
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (&DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
*** ../../e2/egcs/gcc/simplify-rtx.c	Sun Nov  4 21:19:24 2001
--- simplify-rtx.c	Sun Nov 11 18:33:51 2001
*************** simplify_subreg (outermode, op, innermod
*** 2587,2593 ****
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	return gen_rtx_REG (outermode, final_regno);
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are
--- 2587,2604 ----
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	{
! 	  rtx x = gen_rtx_REG (outermode, final_regno);
! 
! 	  /* Propagate original regno.  We don't have any way to specify
! 	     the offset inside orignal regno, so do so only for lowpart.
! 	     The information is used only by alias analysis that can not
! 	     grog partial register anyway.  */
! 
! 	  if (subreg_lowpart_offset (outermode, innermode) == byte)
! 	    ORIGINAL_REGNO (x) = ORIGINAL_REGNO (op);
! 	  return x;
! 	}
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are

^ permalink raw reply	[flat|nested] 19+ messages in thread

* cleanup alter_subreg; fix simplify_subreg
  2001-11-01  5:45 cleanup alter_subreg; fix simplify_subreg Jan Hubicka
                   ` (5 preceding siblings ...)
  2001-11-13 15:03 ` Krister Walfridsson
@ 2001-11-13 15:03 ` Jan Hubicka
  2001-11-13 15:03 ` Jan Hubicka
  7 siblings, 0 replies; 19+ messages in thread
From: Jan Hubicka @ 2001-11-13 15:03 UTC (permalink / raw)
  To: gcc-patches, patches, rth


Hi,
this patch avoid replacing of SUBREG by REG at place in alter_subreg
and cleans it up by calling simplify_subreg instead.

This fixes several problems in my future patch and makes everything
cleaner.

Bootstrapped/regtested i686
Honza

Sun Nov 11 19:53:52 CET 2001  Jan Hubicka  <jh@suse.cz>

	* dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
	* final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
	(final_scan_insn): Update call of alter_subreg.
	(cleanup_subreg_operands): Likewise.
	(alter_subreg): Rewrite using simplify_subreg.
	(output_address, output_operand): Update call of alter_subreg.
	* output.h (alter_subreg): Update prototype.
	* sdbout.c (sdbout_symbol): Update call of alter_subreg.
	* simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.

*** ../../e2/egcs/gcc/dbxout.c	Sat Nov 10 22:32:27 2001
--- dbxout.c	Sun Nov 11 18:22:24 2001
*************** dbxout_symbol_location (decl, type, suff
*** 2107,2113 ****
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (home);
      }
    if (GET_CODE (home) == REG)
      {
--- 2107,2113 ----
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (&home);
      }
    if (GET_CODE (home) == REG)
      {
*** ../../e2/egcs/gcc/final.c	Thu Nov  8 16:06:56 2001
--- final.c	Sun Nov 11 18:53:22 2001
*************** static void profile_after_prologue PARAM
*** 242,248 ****
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
--- 243,249 ----
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx *));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
*************** final_scan_insn (insn, file, optimize, p
*** 2631,2645 ****
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
--- 2632,2646 ----
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (&SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (&XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (&XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
*************** cleanup_subreg_operands (insn)
*** 3001,3021 ****
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (*recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (*recog_data.dup_loc[i]);
      }
  }
  
--- 3002,3022 ----
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand_loc[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand_loc[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (recog_data.dup_loc[i]);
      }
  }
  
*************** cleanup_subreg_operands (insn)
*** 3023,3088 ****
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (x)
!      rtx x;
  {
    rtx y = SUBREG_REG (x);
  
!   if (GET_CODE (y) == SUBREG)
!     y = alter_subreg (y);
! 
!   /* If reload is operating, we may be replacing inside this SUBREG.
!      Check for that and make a new one if so.  */
!   if (reload_in_progress && find_replacement (&SUBREG_REG (x)) != 0)
!     x = copy_rtx (x);
! 
!   if (GET_CODE (y) == REG)
!     {
!       int regno = subreg_hard_regno (x, 1);
! 
!       PUT_CODE (x, REG);
!       REGNO (x) = regno;
!       ORIGINAL_REGNO (x) = ORIGINAL_REGNO (y);
!       /* This field has a different meaning for REGs and SUBREGs.  Make sure
! 	 to clear it!  */
!       x->used = 0;
!     }
!   else if (GET_CODE (y) == MEM)
      {
!       HOST_WIDE_INT offset = SUBREG_BYTE (x);
! 
!       /* Catch these instead of generating incorrect code.  */
!       if ((offset % GET_MODE_SIZE (GET_MODE (x))) != 0)
! 	abort ();
! 
!       PUT_CODE (x, MEM);
!       MEM_COPY_ATTRIBUTES (x, y);
!       XEXP (x, 0) = plus_constant (XEXP (y, 0), offset);
      }
! 
!   return x;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (x)
!      rtx x;
  {
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (x);
  
      default:
        break;
--- 3024,3070 ----
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    rtx y = SUBREG_REG (x);
  
!   /* simplify_subreg does not remove subreg from volatile references.
!      We are required to.  */
!   if (GET_CODE (y) == MEM)
!     *xp = adjust_address (y, GET_MODE (x), SUBREG_BYTE (x));
!   else
      {
!       rtx new = simplify_subreg (GET_MODE (x), y, GET_MODE (y), SUBREG_BYTE (x));
!       if (!new)
! 	debug_rtx (x);
!       *xp = new;
      }
!   return *xp;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (xp);
  
      default:
        break;
*************** output_operand (x, code)
*** 3621,3627 ****
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
--- 3609,3615 ----
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (&x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
*************** void
*** 3640,3646 ****
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
--- 3628,3634 ----
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (&x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
*** ../../e2/egcs/gcc/output.h	Thu Nov  8 16:24:14 2001
--- output.h	Sun Nov 11 18:22:40 2001
*************** extern rtx final_scan_insn	PARAMS ((rtx,
*** 77,83 ****
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
--- 77,83 ----
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx *));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
*** ../../e2/egcs/gcc/sdbout.c	Sun Nov  4 21:19:24 2001
--- sdbout.c	Sun Nov 11 18:21:03 2001
*************** sdbout_symbol (decl, local)
*** 809,815 ****
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
--- 809,815 ----
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (&DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
*** ../../e2/egcs/gcc/simplify-rtx.c	Sun Nov  4 21:19:24 2001
--- simplify-rtx.c	Sun Nov 11 18:33:51 2001
*************** simplify_subreg (outermode, op, innermod
*** 2587,2593 ****
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	return gen_rtx_REG (outermode, final_regno);
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are
--- 2587,2604 ----
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	{
! 	  rtx x = gen_rtx_REG (outermode, final_regno);
! 
! 	  /* Propagate original regno.  We don't have any way to specify
! 	     the offset inside orignal regno, so do so only for lowpart.
! 	     The information is used only by alias analysis that can not
! 	     grog partial register anyway.  */
! 
! 	  if (subreg_lowpart_offset (outermode, innermode) == byte)
! 	    ORIGINAL_REGNO (x) = ORIGINAL_REGNO (op);
! 	  return x;
! 	}
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
  2001-11-13 15:03 ` Krister Walfridsson
@ 2001-11-13 15:03   ` Jan Hubicka
  2001-11-13 15:03     ` Eric Christopher
  0 siblings, 1 reply; 19+ messages in thread
From: Jan Hubicka @ 2001-11-13 15:03 UTC (permalink / raw)
  To: Krister Walfridsson, gcc-patches

> The change
> 
>   Wed Nov 14 14:17:05 CET 2001  Jan Hubicka  <jh@suse.cz>
> 
>         * dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
>         * final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
>         (final_scan_insn): Update call of alter_subreg.
>         (cleanup_subreg_operands): Likewise.
>         (alter_subreg): Rewrite using simplify_subreg.
>         (output_address, output_operand): Update call of alter_subreg.
>         * output.h (alter_subreg): Update prototype.
>         * sdbout.c (sdbout_symbol): Update call of alter_subreg.
>         * simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.
>         * Makefile.in (final.o): Add depdendancy on expr.h
> 
> causes a segmentation fault during bootstrap for arm-unknown-netbsd1.5Y.
Thanks,
I will try to debug this at monday (I can't do much work till then).
The problem appears to be that some ports construct subregs they claim
to be invalid and thus simplify_subreg returns NULL.
I plan to solve it by adding simplify_subreg_force that will do the
simplification even when the results does not validate.

Honza
> 
> I have attached a small .i file that triggers this bug, compiled as
> 
>   > ./xgcc -B./ -O2 -c bug.c --save-temps
>   bug.c: In function `__register_frame_info_bases':
>   bug.c:35: Internal error: Segmentation fault
>   Please submit a full bug report,
>   with preprocessed source if appropriate.
>   See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
> 
>    /Krister
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
  2001-11-03 23:30 ` Richard Henderson
  2001-11-13  4:26   ` Richard Henderson
@ 2001-11-13 15:03   ` Richard Henderson
  1 sibling, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2001-11-13 15:03 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches, patches

On Sun, Nov 11, 2001 at 05:47:05PM +0100, Jan Hubicka wrote:
> 	* dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
> 	* final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
> 	(final_scan_insn): Update call of alter_subreg.
> 	(cleanup_subreg_operands): Likewise.
> 	(alter_subreg): Rewrite using simplify_subreg.
> 	(output_address, output_operand): Update call of alter_subreg.
> 	* output.h (alter_subreg): Update prototype.
> 	* sdbout.c (sdbout_symbol): Update call of alter_subreg.
> 	* simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.

Ok, except, 

> !       if (!new)
> ! 	debug_rtx (x);

You left this in.


r~

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
  2001-11-13 15:03   ` Jan Hubicka
@ 2001-11-13 15:03     ` Eric Christopher
  0 siblings, 0 replies; 19+ messages in thread
From: Eric Christopher @ 2001-11-13 15:03 UTC (permalink / raw)
  To: gcc-patches

> I will try to debug this at monday (I can't do much work till then). The
> problem appears to be that some ports construct subregs they claim to be
> invalid and thus simplify_subreg returns NULL. I plan to solve it by
> adding simplify_subreg_force that will do the simplification even when
> the results does not validate.

Is this a good idea or would it be better for the ports to construct
valid subregs and simplify the work that needs to go into the middle of
the compiler?

-eric

-- 
Fridays are not "pants optional"

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
  2001-11-01  5:45 cleanup alter_subreg; fix simplify_subreg Jan Hubicka
                   ` (4 preceding siblings ...)
  2001-11-13 13:40 ` Jan Hubicka
@ 2001-11-13 15:03 ` Krister Walfridsson
  2001-11-13 15:03   ` Jan Hubicka
  2001-11-13 15:03 ` Jan Hubicka
  2001-11-13 15:03 ` Jan Hubicka
  7 siblings, 1 reply; 19+ messages in thread
From: Krister Walfridsson @ 2001-11-13 15:03 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1145 bytes --]

The change

  Wed Nov 14 14:17:05 CET 2001  Jan Hubicka  <jh@suse.cz>

        * dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
        * final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
        (final_scan_insn): Update call of alter_subreg.
        (cleanup_subreg_operands): Likewise.
        (alter_subreg): Rewrite using simplify_subreg.
        (output_address, output_operand): Update call of alter_subreg.
        * output.h (alter_subreg): Update prototype.
        * sdbout.c (sdbout_symbol): Update call of alter_subreg.
        * simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.
        * Makefile.in (final.o): Add depdendancy on expr.h

causes a segmentation fault during bootstrap for arm-unknown-netbsd1.5Y.

I have attached a small .i file that triggers this bug, compiled as

  > ./xgcc -B./ -O2 -c bug.c --save-temps
  bug.c: In function `__register_frame_info_bases':
  bug.c:35: Internal error: Segmentation fault
  Please submit a full bug report,
  with preprocessed source if appropriate.
  See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

   /Krister


[-- Attachment #2: Type: APPLICATION/octet-stream, Size: 284 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* cleanup alter_subreg; fix simplify_subreg
  2001-11-01  5:45 cleanup alter_subreg; fix simplify_subreg Jan Hubicka
                   ` (6 preceding siblings ...)
  2001-11-13 15:03 ` Jan Hubicka
@ 2001-11-13 15:03 ` Jan Hubicka
  7 siblings, 0 replies; 19+ messages in thread
From: Jan Hubicka @ 2001-11-13 15:03 UTC (permalink / raw)
  To: gcc-patches, patches, rth

Hi,
this patch avoid replacing of SUBREG by REG at place in alter_subreg
and cleans it up by calling simplify_subreg instead.

This fixes several problems in my future patch and makes everything
cleaner.

Bootstrapped/regtested i686
Honza

Sun Nov 11 19:53:52 CET 2001  Jan Hubicka  <jh@suse.cz>

	* dbxout.c (dbxout_symbol_location): Update call of alter_subreg.
	* final.c (walk_alter_subreg): Take pointer; update call of alter_subreg.
	(final_scan_insn): Update call of alter_subreg.
	(cleanup_subreg_operands): Likewise.
	(alter_subreg): Rewrite using simplify_subreg.
	(output_address, output_operand): Update call of alter_subreg.
	* output.h (alter_subreg): Update prototype.
	* sdbout.c (sdbout_symbol): Update call of alter_subreg.
	* simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.

*** ../../e2/egcs/gcc/dbxout.c	Sat Nov 10 22:32:27 2001
--- dbxout.c	Sun Nov 11 18:22:24 2001
*************** dbxout_symbol_location (decl, type, suff
*** 2107,2113 ****
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (home);
      }
    if (GET_CODE (home) == REG)
      {
--- 2107,2113 ----
  	  if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  	    return 0;
  	}
!       home = alter_subreg (&home);
      }
    if (GET_CODE (home) == REG)
      {
*** ../../e2/egcs/gcc/final.c	Thu Nov  8 16:06:56 2001
--- final.c	Sun Nov 11 18:53:22 2001
*************** static void profile_after_prologue PARAM
*** 242,248 ****
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
--- 243,249 ----
  static void add_bb		PARAMS ((FILE *));
  static int add_bb_string	PARAMS ((const char *, int));
  static void notice_source_line	PARAMS ((rtx));
! static rtx walk_alter_subreg	PARAMS ((rtx *));
  static void output_asm_name	PARAMS ((void));
  static tree get_decl_from_op	PARAMS ((rtx, int *));
  static void output_asm_operand_names PARAMS ((rtx *, int *, int));
*************** final_scan_insn (insn, file, optimize, p
*** 2631,2645 ****
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
--- 2632,2646 ----
  		&& insn != last_ignored_compare)
  	      {
  		if (GET_CODE (SET_SRC (set)) == SUBREG)
! 		  SET_SRC (set) = alter_subreg (&SET_SRC (set));
  		else if (GET_CODE (SET_SRC (set)) == COMPARE)
  		  {
  		    if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
  		      XEXP (SET_SRC (set), 0)
! 			= alter_subreg (&XEXP (SET_SRC (set), 0));
  		    if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
  		      XEXP (SET_SRC (set), 1)
! 			= alter_subreg (&XEXP (SET_SRC (set), 1));
  		  }
  		if ((cc_status.value1 != 0
  		     && rtx_equal_p (SET_SRC (set), cc_status.value1))
*************** cleanup_subreg_operands (insn)
*** 3001,3021 ****
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (*recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (*recog_data.dup_loc[i]);
      }
  }
  
--- 3002,3022 ----
    for (i = 0; i < recog_data.n_operands; i++)
      {
        if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand_loc[i]);
        else if (GET_CODE (recog_data.operand[i]) == PLUS
  	       || GET_CODE (recog_data.operand[i]) == MULT
  	       || GET_CODE (recog_data.operand[i]) == MEM)
! 	recog_data.operand[i] = walk_alter_subreg (recog_data.operand_loc[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
        if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
! 	*recog_data.dup_loc[i] = alter_subreg (recog_data.dup_loc[i]);
        else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
  	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
  	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
! 	*recog_data.dup_loc[i] = walk_alter_subreg (recog_data.dup_loc[i]);
      }
  }
  
*************** cleanup_subreg_operands (insn)
*** 3023,3088 ****
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (x)
!      rtx x;
  {
    rtx y = SUBREG_REG (x);
  
!   if (GET_CODE (y) == SUBREG)
!     y = alter_subreg (y);
! 
!   /* If reload is operating, we may be replacing inside this SUBREG.
!      Check for that and make a new one if so.  */
!   if (reload_in_progress && find_replacement (&SUBREG_REG (x)) != 0)
!     x = copy_rtx (x);
! 
!   if (GET_CODE (y) == REG)
!     {
!       int regno = subreg_hard_regno (x, 1);
! 
!       PUT_CODE (x, REG);
!       REGNO (x) = regno;
!       ORIGINAL_REGNO (x) = ORIGINAL_REGNO (y);
!       /* This field has a different meaning for REGs and SUBREGs.  Make sure
! 	 to clear it!  */
!       x->used = 0;
!     }
!   else if (GET_CODE (y) == MEM)
      {
!       HOST_WIDE_INT offset = SUBREG_BYTE (x);
! 
!       /* Catch these instead of generating incorrect code.  */
!       if ((offset % GET_MODE_SIZE (GET_MODE (x))) != 0)
! 	abort ();
! 
!       PUT_CODE (x, MEM);
!       MEM_COPY_ATTRIBUTES (x, y);
!       XEXP (x, 0) = plus_constant (XEXP (y, 0), offset);
      }
! 
!   return x;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (x)
!      rtx x;
  {
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (x);
  
      default:
        break;
--- 3024,3070 ----
     based on the thing it is a subreg of.  */
  
  rtx
! alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    rtx y = SUBREG_REG (x);
  
!   /* simplify_subreg does not remove subreg from volatile references.
!      We are required to.  */
!   if (GET_CODE (y) == MEM)
!     *xp = adjust_address (y, GET_MODE (x), SUBREG_BYTE (x));
!   else
      {
!       rtx new = simplify_subreg (GET_MODE (x), y, GET_MODE (y), SUBREG_BYTE (x));
!       if (!new)
! 	debug_rtx (x);
!       *xp = new;
      }
!   return *xp;
  }
  
  /* Do alter_subreg on all the SUBREGs contained in X.  */
  
  static rtx
! walk_alter_subreg (xp)
!      rtx *xp;
  {
+   rtx x = *xp;
    switch (GET_CODE (x))
      {
      case PLUS:
      case MULT:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
!       XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1));
        break;
  
      case MEM:
!       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0));
        break;
  
      case SUBREG:
!       return alter_subreg (xp);
  
      default:
        break;
*************** output_operand (x, code)
*** 3621,3627 ****
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
--- 3609,3615 ----
       int code ATTRIBUTE_UNUSED;
  {
    if (x && GET_CODE (x) == SUBREG)
!     x = alter_subreg (&x);
  
    /* If X is a pseudo-register, abort now rather than writing trash to the
       assembler file.  */
*************** void
*** 3640,3646 ****
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
--- 3628,3634 ----
  output_address (x)
       rtx x;
  {
!   walk_alter_subreg (&x);
    PRINT_OPERAND_ADDRESS (asm_out_file, x);
  }
  \f
*** ../../e2/egcs/gcc/output.h	Thu Nov  8 16:24:14 2001
--- output.h	Sun Nov 11 18:22:40 2001
*************** extern rtx final_scan_insn	PARAMS ((rtx,
*** 77,83 ****
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
--- 77,83 ----
  
  /* Replace a SUBREG with a REG or a MEM, based on the thing it is a
     subreg of.  */
! extern rtx alter_subreg PARAMS ((rtx *));
  
  /* Report inconsistency between the assembler template and the operands.
     In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
*** ../../e2/egcs/gcc/sdbout.c	Sun Nov  4 21:19:24 2001
--- sdbout.c	Sun Nov 11 18:21:03 2001
*************** sdbout_symbol (decl, local)
*** 809,815 ****
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
--- 809,815 ----
  	      if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
  		return;
  	    }
! 	  regno = REGNO (alter_subreg (&DECL_RTL (decl)));
  	  value = DECL_RTL (decl);
  	}
        /* Don't output anything if an auto variable
*** ../../e2/egcs/gcc/simplify-rtx.c	Sun Nov  4 21:19:24 2001
--- simplify-rtx.c	Sun Nov 11 18:33:51 2001
*************** simplify_subreg (outermode, op, innermod
*** 2587,2593 ****
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	return gen_rtx_REG (outermode, final_regno);
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are
--- 2587,2604 ----
  	 arguments are passed on 32-bit Sparc and should be fixed.  */
        if (HARD_REGNO_MODE_OK (final_regno, outermode)
  	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
! 	{
! 	  rtx x = gen_rtx_REG (outermode, final_regno);
! 
! 	  /* Propagate original regno.  We don't have any way to specify
! 	     the offset inside orignal regno, so do so only for lowpart.
! 	     The information is used only by alias analysis that can not
! 	     grog partial register anyway.  */
! 
! 	  if (subreg_lowpart_offset (outermode, innermode) == byte)
! 	    ORIGINAL_REGNO (x) = ORIGINAL_REGNO (op);
! 	  return x;
! 	}
      }
  
    /* If we have a SUBREG of a register that we are replacing and we are

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
  2001-11-13 15:03 ` Jan Hubicka
@ 2001-11-22  4:45   ` Jan Hubicka
  0 siblings, 0 replies; 19+ messages in thread
From: Jan Hubicka @ 2001-11-22  4:45 UTC (permalink / raw)
  To: Kaveh R. Ghazi; +Cc: cato, jh, gcc-bugs, gcc-patches

>  > > The change
>  > > 
>  > >   Wed Nov 14 14:17:05 CET 2001  Jan Hubicka  <jh@suse.cz>
>  > > 
>  > >         * dbxout.c (dbxout_symbol_location): Update call of
>  > > alter_subreg.
>  > >         * final.c (walk_alter_subreg): Take pointer; update call of
>  > > alter_subreg.
>  > >         (final_scan_insn): Update call of alter_subreg.
>  > >         (cleanup_subreg_operands): Likewise.
>  > >         (alter_subreg): Rewrite using simplify_subreg.
>  > >         (output_address, output_operand): Update call of
>  > > alter_subreg.
>  > >         * output.h (alter_subreg): Update prototype.
>  > >         * sdbout.c (sdbout_symbol): Update call of alter_subreg.
>  > >         * simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.
>  > >         * Makefile.in (final.o): Add depdendancy on expr.h
>  > > 
>  > > causes a segmentation fault during bootstrap for
>  > > arm-unknown-netbsd1.5Y.
>  > 
>  > Thanks,
>  > I will try to debug this at monday (I can't do much work till then).
>  > The problem appears to be that some ports construct subregs they claim
>  > to be invalid and thus simplify_subreg returns NULL.  I plan to solve
>  > it by adding simplify_subreg_force that will do the simplification
>  > even when the results does not validate.
>  > Honza
> 
> Jan,
> 
> I'm pretty sure your change also broke solaris2 bootstraps.  The sparc
> port has a bunch of calls to alter_subreg and none of them appear to
> have been updated as per your parameter change.  See:
> http://gcc.gnu.org/ml/gcc-bugs/2001-11/msg00519.html
> 
> 
> In fact, there are about 10 port subdirectories which call
> alter_subreg, and none of them seem to have gotten this change
> propagated.  IMHO this patch shouldn't have been checked in without
> catching all callers, "grep" is your friend.
Yes, I did grep only on the base directory.  My apologizes for that - I didn't
expected the alter subreg to be used elsewhere.  IMO the uses should be
slowly converted to simplify_subreg instead.
> 
> When do you expect to address this problem?
I am just working on it - I do have sparc tree bootstrapping again.

Honza
> 
> 		Thanks,
> 		--Kaveh
> --
> Kaveh R. Ghazi			Engagement Manager / Project Services
> ghazi@caip.rutgers.edu		Qwest Internet Solutions

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
  2001-11-13 15:03 ` Hans-Peter Nilsson
@ 2001-11-21 19:10   ` Hans-Peter Nilsson
  0 siblings, 0 replies; 19+ messages in thread
From: Hans-Peter Nilsson @ 2001-11-21 19:10 UTC (permalink / raw)
  To: Kaveh R. Ghazi; +Cc: gcc-bugs, gcc-patches

On Wed, 21 Nov 2001, Kaveh R. Ghazi wrote:
> Jan,
>
> I'm pretty sure your change also broke solaris2 bootstraps.  The sparc
> port has a bunch of calls to alter_subreg and none of them appear to
> have been updated as per your parameter change.  See:
> http://gcc.gnu.org/ml/gcc-bugs/2001-11/msg00519.html

Maybe alter_subreg calls need changing, I don't know.  If it's
not that, then maybe it's because sparc.md uses define_peephole
which was also broken by that patch.  For laughs, try
<URL: http://gcc.gnu.org/ml/gcc-patches/2001-11/msg01407.html >.
It helped a bit on the road for arm-elf, but didn't solve the
build problem.  (Sorry: I see no SPARC here.)

brgds, H-P

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
  2001-11-13 15:03 Kaveh R. Ghazi
  2001-11-13 15:03 ` Hans-Peter Nilsson
  2001-11-13 15:03 ` Jan Hubicka
@ 2001-11-21 18:08 ` Kaveh R. Ghazi
  2 siblings, 0 replies; 19+ messages in thread
From: Kaveh R. Ghazi @ 2001-11-21 18:08 UTC (permalink / raw)
  To: cato, jh; +Cc: gcc-bugs, gcc-patches

 > > The change
 > > 
 > >   Wed Nov 14 14:17:05 CET 2001  Jan Hubicka  <jh@suse.cz>
 > > 
 > >         * dbxout.c (dbxout_symbol_location): Update call of
 > > alter_subreg.
 > >         * final.c (walk_alter_subreg): Take pointer; update call of
 > > alter_subreg.
 > >         (final_scan_insn): Update call of alter_subreg.
 > >         (cleanup_subreg_operands): Likewise.
 > >         (alter_subreg): Rewrite using simplify_subreg.
 > >         (output_address, output_operand): Update call of
 > > alter_subreg.
 > >         * output.h (alter_subreg): Update prototype.
 > >         * sdbout.c (sdbout_symbol): Update call of alter_subreg.
 > >         * simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.
 > >         * Makefile.in (final.o): Add depdendancy on expr.h
 > > 
 > > causes a segmentation fault during bootstrap for
 > > arm-unknown-netbsd1.5Y.
 > 
 > Thanks,
 > I will try to debug this at monday (I can't do much work till then).
 > The problem appears to be that some ports construct subregs they claim
 > to be invalid and thus simplify_subreg returns NULL.  I plan to solve
 > it by adding simplify_subreg_force that will do the simplification
 > even when the results does not validate.
 > Honza

Jan,

I'm pretty sure your change also broke solaris2 bootstraps.  The sparc
port has a bunch of calls to alter_subreg and none of them appear to
have been updated as per your parameter change.  See:
http://gcc.gnu.org/ml/gcc-bugs/2001-11/msg00519.html


In fact, there are about 10 port subdirectories which call
alter_subreg, and none of them seem to have gotten this change
propagated.  IMHO this patch shouldn't have been checked in without
catching all callers, "grep" is your friend.

When do you expect to address this problem?

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
  2001-11-13 15:03 Kaveh R. Ghazi
@ 2001-11-13 15:03 ` Hans-Peter Nilsson
  2001-11-21 19:10   ` Hans-Peter Nilsson
  2001-11-13 15:03 ` Jan Hubicka
  2001-11-21 18:08 ` Kaveh R. Ghazi
  2 siblings, 1 reply; 19+ messages in thread
From: Hans-Peter Nilsson @ 2001-11-13 15:03 UTC (permalink / raw)
  To: Kaveh R. Ghazi; +Cc: gcc-bugs, gcc-patches

On Wed, 21 Nov 2001, Kaveh R. Ghazi wrote:
> Jan,
>
> I'm pretty sure your change also broke solaris2 bootstraps.  The sparc
> port has a bunch of calls to alter_subreg and none of them appear to
> have been updated as per your parameter change.  See:
> http://gcc.gnu.org/ml/gcc-bugs/2001-11/msg00519.html

Maybe alter_subreg calls need changing, I don't know.  If it's
not that, then maybe it's because sparc.md uses define_peephole
which was also broken by that patch.  For laughs, try
<URL:http://gcc.gnu.org/ml/gcc-patches/2001-11/msg01407.html>.
It helped a bit on the road for arm-elf, but didn't solve the
build problem.  (Sorry: I see no SPARC here.)

brgds, H-P

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
  2001-11-13 15:03 Kaveh R. Ghazi
  2001-11-13 15:03 ` Hans-Peter Nilsson
@ 2001-11-13 15:03 ` Jan Hubicka
  2001-11-22  4:45   ` Jan Hubicka
  2001-11-21 18:08 ` Kaveh R. Ghazi
  2 siblings, 1 reply; 19+ messages in thread
From: Jan Hubicka @ 2001-11-13 15:03 UTC (permalink / raw)
  To: Kaveh R. Ghazi; +Cc: cato, jh, gcc-bugs, gcc-patches

>  > > The change
>  > > 
>  > >   Wed Nov 14 14:17:05 CET 2001  Jan Hubicka  <jh@suse.cz>
>  > > 
>  > >         * dbxout.c (dbxout_symbol_location): Update call of
>  > > alter_subreg.
>  > >         * final.c (walk_alter_subreg): Take pointer; update call of
>  > > alter_subreg.
>  > >         (final_scan_insn): Update call of alter_subreg.
>  > >         (cleanup_subreg_operands): Likewise.
>  > >         (alter_subreg): Rewrite using simplify_subreg.
>  > >         (output_address, output_operand): Update call of
>  > > alter_subreg.
>  > >         * output.h (alter_subreg): Update prototype.
>  > >         * sdbout.c (sdbout_symbol): Update call of alter_subreg.
>  > >         * simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.
>  > >         * Makefile.in (final.o): Add depdendancy on expr.h
>  > > 
>  > > causes a segmentation fault during bootstrap for
>  > > arm-unknown-netbsd1.5Y.
>  > 
>  > Thanks,
>  > I will try to debug this at monday (I can't do much work till then).
>  > The problem appears to be that some ports construct subregs they claim
>  > to be invalid and thus simplify_subreg returns NULL.  I plan to solve
>  > it by adding simplify_subreg_force that will do the simplification
>  > even when the results does not validate.
>  > Honza
> 
> Jan,
> 
> I'm pretty sure your change also broke solaris2 bootstraps.  The sparc
> port has a bunch of calls to alter_subreg and none of them appear to
> have been updated as per your parameter change.  See:
> http://gcc.gnu.org/ml/gcc-bugs/2001-11/msg00519.html
> 
> 
> In fact, there are about 10 port subdirectories which call
> alter_subreg, and none of them seem to have gotten this change
> propagated.  IMHO this patch shouldn't have been checked in without
> catching all callers, "grep" is your friend.
Yes, I did grep only on the base directory.  My apologizes for that - I didn't
expected the alter subreg to be used elsewhere.  IMO the uses should be
slowly converted to simplify_subreg instead.
> 
> When do you expect to address this problem?
I am just working on it - I do have sparc tree bootstrapping again.

Honza
> 
> 		Thanks,
> 		--Kaveh
> --
> Kaveh R. Ghazi			Engagement Manager / Project Services
> ghazi@caip.rutgers.edu		Qwest Internet Solutions

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: cleanup alter_subreg; fix simplify_subreg
@ 2001-11-13 15:03 Kaveh R. Ghazi
  2001-11-13 15:03 ` Hans-Peter Nilsson
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Kaveh R. Ghazi @ 2001-11-13 15:03 UTC (permalink / raw)
  To: cato, jh; +Cc: gcc-bugs, gcc-patches

 > > The change
 > > 
 > >   Wed Nov 14 14:17:05 CET 2001  Jan Hubicka  <jh@suse.cz>
 > > 
 > >         * dbxout.c (dbxout_symbol_location): Update call of
 > > alter_subreg.
 > >         * final.c (walk_alter_subreg): Take pointer; update call of
 > > alter_subreg.
 > >         (final_scan_insn): Update call of alter_subreg.
 > >         (cleanup_subreg_operands): Likewise.
 > >         (alter_subreg): Rewrite using simplify_subreg.
 > >         (output_address, output_operand): Update call of
 > > alter_subreg.
 > >         * output.h (alter_subreg): Update prototype.
 > >         * sdbout.c (sdbout_symbol): Update call of alter_subreg.
 > >         * simplify-rtx.c (simplify_subreg): Copy ORIGINAL_REGNO.
 > >         * Makefile.in (final.o): Add depdendancy on expr.h
 > > 
 > > causes a segmentation fault during bootstrap for
 > > arm-unknown-netbsd1.5Y.
 > 
 > Thanks,
 > I will try to debug this at monday (I can't do much work till then).
 > The problem appears to be that some ports construct subregs they claim
 > to be invalid and thus simplify_subreg returns NULL.  I plan to solve
 > it by adding simplify_subreg_force that will do the simplification
 > even when the results does not validate.
 > Honza

Jan,

I'm pretty sure your change also broke solaris2 bootstraps.  The sparc
port has a bunch of calls to alter_subreg and none of them appear to
have been updated as per your parameter change.  See:
http://gcc.gnu.org/ml/gcc-bugs/2001-11/msg00519.html


In fact, there are about 10 port subdirectories which call
alter_subreg, and none of them seem to have gotten this change
propagated.  IMHO this patch shouldn't have been checked in without
catching all callers, "grep" is your friend.

When do you expect to address this problem?

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2001-11-22 12:45 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-01  5:45 cleanup alter_subreg; fix simplify_subreg Jan Hubicka
2001-11-03 23:30 ` Richard Henderson
2001-11-13  4:26   ` Richard Henderson
2001-11-13 15:03   ` Richard Henderson
2001-11-12 12:11 ` Jan Hubicka
2001-11-13  4:26 ` Jan Hubicka
2001-11-13  5:27 ` Jan Hubicka
2001-11-13 13:40 ` Jan Hubicka
2001-11-13 15:03 ` Krister Walfridsson
2001-11-13 15:03   ` Jan Hubicka
2001-11-13 15:03     ` Eric Christopher
2001-11-13 15:03 ` Jan Hubicka
2001-11-13 15:03 ` Jan Hubicka
2001-11-13 15:03 Kaveh R. Ghazi
2001-11-13 15:03 ` Hans-Peter Nilsson
2001-11-21 19:10   ` Hans-Peter Nilsson
2001-11-13 15:03 ` Jan Hubicka
2001-11-22  4:45   ` Jan Hubicka
2001-11-21 18:08 ` Kaveh R. Ghazi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).