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


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

Fix rtl sharing in ifcvt try 2


Hi,
here is updated patch for ifcvt.  As requested it now does use
unshare_all_rtl machinery.

Regtester/bootstrapped i386.  OK?
Wed May 21 23:04:58 CEST 2003  Jan Hubicka  <jh@suse.cz>
	* emit-rtl.c (unshare_all_rtl_in_chain): New function.
	* rtl.h (unshare_all_rtl_in_chain): Declare it.
	* ifcvt.c (noce_try_store_flag, noce_try_store_flag_inc,
	 noce_try_store_flag_mask, noce_try_cmove,
	 noce_try_cmove_arith, noce_try_minmax, noce_try_abs,
	 noce_process_if_block): Use it.
	(noce_emit_*): Copy the arguments to avoid sharing.
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.336
diff -c -3 -p -r1.336 emit-rtl.c
*** emit-rtl.c	27 Jun 2003 09:49:30 -0000	1.336
--- emit-rtl.c	27 Jun 2003 19:48:42 -0000
*************** unshare_all_rtl_again (insn)
*** 2626,2631 ****
--- 2626,2651 ----
    unshare_all_rtl (cfun->decl, insn);
  }
  
+ /* Go through all the RTL insn chain starting by INSN and unshare all RTL.
+    This can be used to avoid RTL sharing problems after expanding complex
+    sequences, like ifcvt do.  */
+ 
+ void
+ unshare_all_rtl_in_chain (insn)
+      rtx insn;
+ {
+   rtx p;
+ 
+   for (p = insn; p; p = NEXT_INSN (p))
+     if (INSN_P (p))
+       {
+ 	reset_used_flags (PATTERN (p));
+ 	reset_used_flags (REG_NOTES (p));
+ 	reset_used_flags (LOG_LINKS (p));
+       }
+   unshare_all_rtl_1 (insn);
+ }
+ 
  /* Go through all the RTL insn bodies and copy any invalid shared structure.
     Assumes the mark bits are cleared at entry.  */
  
Index: ifcvt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ifcvt.c,v
retrieving revision 1.120
diff -c -3 -p -r1.120 ifcvt.c
*** ifcvt.c	16 Jun 2003 21:41:05 -0000	1.120
--- ifcvt.c	27 Jun 2003 19:48:42 -0000
*************** noce_emit_store_flag (if_info, x, revers
*** 622,627 ****
--- 622,633 ----
    else
      code = GET_CODE (cond);
  
+   /* Even tought we take care to unshare seqeuence after emit, we have
+      to unshare it's arguments so we don't get sharing in between
+      the sequence and outer chain.  */
+   cond = copy_rtx (cond);
+   x = copy_rtx (x);
+ 
    if ((if_info->cond_earliest == if_info->jump || cond_complex)
        && (normalize == 0 || STORE_FLAG_VALUE == normalize))
      {
*************** noce_emit_move_insn (x, y)
*** 667,672 ****
--- 673,684 ----
    rtx outer, inner;
    int bitpos;
  
+   /* Even tought we take care to unshare seqeuence after emit, we have
+      to unshare it's arguments so we don't get sharing in between
+      the sequence and outer chain.  */
+   x = copy_rtx (x);
+   y = copy_rtx (y);
+ 
    if (GET_CODE (x) != STRICT_LOW_PART)
      {
        emit_move_insn (x, y);
*************** noce_try_addcc (if_info)
*** 887,896 ****
  	  && general_operand (XEXP (cond, 1), VOIDmode))
  	{
  	  start_sequence ();
! 	  target = emit_conditional_add (if_info->x, code,
! 					 XEXP (cond, 0), XEXP (cond, 1),
  					 VOIDmode,
! 					 if_info->b, XEXP (if_info->a, 1),
  					 GET_MODE (if_info->x),
  					 (code == LTU || code == GEU
  					  || code == LEU || code == GTU));
--- 899,910 ----
  	  && general_operand (XEXP (cond, 1), VOIDmode))
  	{
  	  start_sequence ();
! 	  target = emit_conditional_add (copy_rtx (if_info->x), code,
! 					 copy_rtx (XEXP (cond, 0)),
! 					 copy_rtx (XEXP (cond, 1)),
  					 VOIDmode,
! 					 copy_rtx (if_info->b),
! 					 copy_rtx (XEXP (if_info->a, 1)),
  					 GET_MODE (if_info->x),
  					 (code == LTU || code == GEU
  					  || code == LEU || code == GTU));
*************** noce_try_store_flag_mask (if_info)
*** 982,988 ****
  				     reversep, -1);
        if (target)
          target = expand_simple_binop (GET_MODE (if_info->x), AND,
! 				      if_info->x, target, if_info->x, 0,
  				      OPTAB_WIDEN);
  
        if (target)
--- 996,1003 ----
  				     reversep, -1);
        if (target)
          target = expand_simple_binop (GET_MODE (if_info->x), AND,
! 				      copy_rtx (if_info->x),
! 				      target, copy_rtx (if_info->x), 0,
  				      OPTAB_WIDEN);
  
        if (target)
*************** noce_emit_cmove (if_info, x, code, cmp_a
*** 1016,1021 ****
--- 1031,1045 ----
       rtx x, cmp_a, cmp_b, vfalse, vtrue;
       enum rtx_code code;
  {
+   /* Even tought we take care to unshare seqeuence after emit, we have
+      to unshare it's arguments so we don't get sharing in between
+      the sequence and outer chain.  */
+   x = copy_rtx (x);
+   cmp_a = copy_rtx (cmp_a);
+   cmp_b = copy_rtx (cmp_b);
+   vfalse = copy_rtx (vfalse);
+   vtrue = copy_rtx (vtrue);
+ 
    /* If earliest == jump, try to build the cmove insn directly.
       This is helpful when combine has created some complex condition
       (like for alpha's cmovlbs) that we can't hope to regenerate
*************** noce_try_cmove_arith (if_info)
*** 1209,1215 ****
        if (is_mem)
  	{
            tmp = gen_reg_rtx (GET_MODE (b));
! 	  tmp = emit_insn (gen_rtx_SET (VOIDmode, tmp, b));
  	}
        else if (! insn_b)
  	goto end_seq_and_fail;
--- 1233,1241 ----
        if (is_mem)
  	{
            tmp = gen_reg_rtx (GET_MODE (b));
! 	  tmp = emit_insn (gen_rtx_SET (VOIDmode,
! 				  	copy_rtx (tmp),
! 					copy_rtx (b)));
  	}
        else if (! insn_b)
  	goto end_seq_and_fail;
*************** noce_try_cmove_arith (if_info)
*** 1218,1224 ****
            b = gen_reg_rtx (GET_MODE (b));
  	  tmp = copy_rtx (insn_b);
  	  set = single_set (tmp);
! 	  SET_DEST (set) = b;
  	  tmp = emit_insn (PATTERN (tmp));
  	}
        if (recog_memoized (tmp) < 0)
--- 1244,1250 ----
            b = gen_reg_rtx (GET_MODE (b));
  	  tmp = copy_rtx (insn_b);
  	  set = single_set (tmp);
! 	  SET_DEST (set) = copy_rtx (b);
  	  tmp = emit_insn (PATTERN (tmp));
  	}
        if (recog_memoized (tmp) < 0)
*************** find_cond_trap (test_bb, then_edge, else
*** 2542,2548 ****
      }
  
    /* Attempt to generate the conditional trap.  */
!   seq = gen_cond_trap (code, XEXP (cond, 0), XEXP (cond, 1),
  		       TRAP_CODE (PATTERN (trap)));
    if (seq == NULL)
      return FALSE;
--- 2568,2575 ----
      }
  
    /* Attempt to generate the conditional trap.  */
!   seq = gen_cond_trap (code, copy_rtx (XEXP (cond, 0)),
! 		       copy_rtx (XEXP (cond, 1)),
  		       TRAP_CODE (PATTERN (trap)));
    if (seq == NULL)
      return FALSE;
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.420
diff -c -3 -p -r1.420 rtl.h
*** rtl.h	27 Jun 2003 09:49:35 -0000	1.420
--- rtl.h	27 Jun 2003 19:48:42 -0000
*************** extern void set_new_first_and_last_insn	
*** 2065,2070 ****
--- 2065,2071 ----
  extern void set_new_first_and_last_label_num	PARAMS ((int, int));
  extern void set_new_last_label_num		PARAMS ((int));
  extern void unshare_all_rtl_again		PARAMS ((rtx));
+ extern void unshare_all_rtl_in_chain		PARAMS ((rtx));
  extern void set_first_insn			PARAMS ((rtx));
  extern void set_last_insn			PARAMS ((rtx));
  extern void link_cc0_insns			PARAMS ((rtx));


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