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


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

Re: Autoincrement patches


Well, when looking at your examples, I've found that there was a problem
in combine.c - it choked because undobuf was not zeroed after loop had
made use of validate_subst* functions.
optimize_related_values didn't recognize the c4x kind of adds.
The regular stuff in regmove_optimize didn't know about PRE_MODIFY /
POST_MODIFY.
And when I transformed your postincw2.c example to use pre-decrement
and tested it on the SH, I've found a borderline case where a pre-decrement
opportunity was missed.

But all this probably won't help the c4x...

*** combine.c-19991220	Mon Dec 20 20:42:05 1999
--- combine.c	Mon Dec 20 20:51:38 1999
*************** combine_instructions (f, nregs)
*** 499,504 ****
--- 499,506 ----
    combine_extras = 0;
    combine_successes = 0;
  
+   bzero ((char *) &undobuf, sizeof (undobuf));
+ 
    combine_max_regno = nregs;
  
    reg_nonzero_bits = ((unsigned HOST_WIDE_INT *) 
*** regmove.c-1999121804	Sat Dec 18 04:36:10 1999
--- regmove.c	Tue Dec 21 00:04:24 1999
*************** try_auto_increment (insn, inc_insn, inc_
*** 156,161 ****
--- 156,162 ----
       int pre;
  {
    enum rtx_code inc_code;
+   rtx addr = NULL_RTX;
  
    rtx pset = single_set (insn);
    if (pset)
*************** try_auto_increment (insn, inc_insn, inc_
*** 176,202 ****
  	      || (HAVE_PRE_DECREMENT
  		  && pre == 1 && (inc_code = PRE_DEC, increment == -size))
  	  )
! 	    {
! 	      if (inc_insn_set)
! 		validate_change
! 		  (inc_insn, 
! 		   &SET_SRC (inc_insn_set),
! 		   XEXP (SET_SRC (inc_insn_set), 0), 1);
! 	      validate_change (insn, &XEXP (use, 0),
! 			       gen_rtx_fmt_e (inc_code, Pmode, reg), 1);
! 	      if (apply_change_group ())
! 		{
! 		  REG_NOTES (insn)
! 		    = gen_rtx_EXPR_LIST (REG_INC,
! 					 reg, REG_NOTES (insn));
! 		  if (! inc_insn_set)
! 		    {
! 		      PUT_CODE (inc_insn, NOTE);
! 		      NOTE_LINE_NUMBER (inc_insn) = NOTE_INSN_DELETED;
! 		      NOTE_SOURCE_FILE (inc_insn) = 0;
! 		    }
! 		  return 1;
  		}
  	    }
  	}
      }
--- 177,207 ----
  	      || (HAVE_PRE_DECREMENT
  		  && pre == 1 && (inc_code = PRE_DEC, increment == -size))
  	  )
! 	    addr = gen_rtx_fmt_e (inc_code, Pmode, reg);
! 	  else if (HAVE_POST_MODIFY_DISP && pre == 0)
! 	    addr = gen_rtx_POST_MODIFY (Pmode, reg, GEN_INT (increment));
! 	  else if (HAVE_PRE_MODIFY_DISP && pre == 1)
! 	    addr = gen_rtx_PRE_MODIFY (Pmode, reg, GEN_INT (increment));
! 	  else
! 	    return 0;
! 	  if (inc_insn_set)
! 	    validate_change
! 	      (inc_insn, 
! 	       &SET_SRC (inc_insn_set),
! 	       XEXP (SET_SRC (inc_insn_set), 0), 1);
! 	  validate_change (insn, &XEXP (use, 0), addr, 1);
! 	  if (apply_change_group ())
! 	    {
! 	      REG_NOTES (insn)
! 		= gen_rtx_EXPR_LIST (REG_INC,
! 				     reg, REG_NOTES (insn));
! 	      if (! inc_insn_set)
! 		{
! 		  PUT_CODE (inc_insn, NOTE);
! 		  NOTE_LINE_NUMBER (inc_insn) = NOTE_INSN_DELETED;
! 		  NOTE_SOURCE_FILE (inc_insn) = 0;
  		}
+ 	      return 1;
  	    }
  	}
      }
*************** find_related (xp, insn, luid, call_tally
*** 1261,1268 ****
--- 1266,1295 ----
        }
      case PARALLEL:
        {
+ 	/* Ignore trailing clobbers of registers that are not member of a set
+ 	   of related values, and are not memntioned elsewhere in the insn.  */
  	for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
  	  {
+ 	    rtx y = XVECEXP (x, 0, i);
+ 	    rtx dst;
+ 
+ 	    if (GET_CODE (y) != CLOBBER)
+ 	      break;
+ 	    dst = XEXP (y, 0);
+ 	    if (GET_CODE (dst) != REG)
+ 	      break;
+ 	    if (regno_related[REGNO (dst)]
+ 		|| count_occurrences (PATTERN (insn), dst) > 1)
+ 	      break;
+ 	  }
+ 	/* If only one part remains, handle this like the non-parallel case.  */
+ 	if (i == 0)
+ 	  {
+ 	    find_related (&XVECEXP (x, 0, i), insn, luid, call_tally);
+ 	    return;
+ 	  }
+ 	for (; i >= 0; i--)
+ 	  {
  	    rtx *yp = &XVECEXP (x, 0, i);
  	    rtx y = *yp;
  	    if (GET_CODE (y) == SET)
*************** optimize_related_values_1 (rel_base, lui
*** 1912,1917 ****
--- 1939,1966 ----
  		  if (addr != reg && GET_CODE (addr) != PLUS)
  		    REG_NOTES (use->insn)
  		      = gen_rtx_EXPR_LIST (REG_INC, reg, REG_NOTES (use->insn));
+ 		  /* If this is the first use in s linked set of chains, we
+ 		     might be able to change the add we created above in the
+ 		     outer loop into a move by using a pre-in/decrement.  */
+ 		  else if (! last_use && addr == reg && use->insn)
+ 		    {
+ 		      rtx add = PREV_INSN (use->insn);
+ 		      rtx set = single_set (add);
+ 
+ 		      if (set
+ 			  && SET_DEST (set) == reg
+ 			  && GET_CODE (SET_SRC (set)) == PLUS)
+ 			{
+ 			  rtx src = XEXP (SET_SRC (set), 0);
+ 			  rtx increment = XEXP (SET_SRC (set), 1);
+ 			  if (GET_CODE (increment) == CONST_INT)
+ 			    {
+ 			      try_auto_increment (use->insn, add,
+ 						  src == reg ? NULL_RTX : set,
+ 						  reg, INTVAL (increment), 1);
+ 			    }
+ 			}
+ 		    }
  		  last_use = use;
  		  last_offset = use->match_offset;
  		}
*************** fixup_match_1 (insn, set, src, src_subre
*** 3681,3687 ****
    if (code == MINUS)
      {
        post_inc = emit_insn_after (copy_rtx (PATTERN (insn)), p);
!       if ((HAVE_PRE_INCREMENT || HAVE_PRE_DECREMENT)
  	  && search_end
  	  && try_auto_increment (search_end, post_inc, 0, src, newconst, 1))
  	post_inc = 0;
--- 3730,3736 ----
    if (code == MINUS)
      {
        post_inc = emit_insn_after (copy_rtx (PATTERN (insn)), p);
!       if ((HAVE_PRE_INCREMENT || HAVE_PRE_DECREMENT || HAVE_PRE_MODIFY_DISP)
  	  && search_end
  	  && try_auto_increment (search_end, post_inc, 0, src, newconst, 1))
  	post_inc = 0;
*************** fixup_match_1 (insn, set, src, src_subre
*** 3696,3702 ****
        rtx pat = PATTERN (insn);
        if (src_note)
  	remove_note (overlap, src_note);
!       if ((HAVE_POST_INCREMENT || HAVE_POST_DECREMENT)
  	  && code == PLUS
  	  && try_auto_increment (overlap, insn, 0, src, insn_const, 0))
  	insn = overlap;
--- 3745,3751 ----
        rtx pat = PATTERN (insn);
        if (src_note)
  	remove_note (overlap, src_note);
!       if ((HAVE_POST_INCREMENT || HAVE_POST_DECREMENT || HAVE_POST_MODIFY_DISP)
  	  && code == PLUS
  	  && try_auto_increment (overlap, insn, 0, src, insn_const, 0))
  	insn = overlap;
*************** fixup_match_1 (insn, set, src, src_subre
*** 3781,3791 ****
  	}
      }
  
!   if ((HAVE_PRE_INCREMENT || HAVE_PRE_DECREMENT)
  	   && (code == PLUS || code == MINUS) && insn_const
  	   && try_auto_increment (p, insn, 0, src, insn_const, 1))
      insn = p;
!   else if ((HAVE_POST_INCREMENT || HAVE_POST_DECREMENT)
  	   && post_inc
  	   && try_auto_increment (p, post_inc, post_inc_set, src, newconst, 0))
      post_inc = 0;
--- 3830,3840 ----
  	}
      }
  
!   if ((HAVE_PRE_INCREMENT || HAVE_PRE_DECREMENT || HAVE_PRE_MODIFY_DISP)
  	   && (code == PLUS || code == MINUS) && insn_const
  	   && try_auto_increment (p, insn, 0, src, insn_const, 1))
      insn = p;
!   else if ((HAVE_POST_INCREMENT || HAVE_POST_DECREMENT || HAVE_POST_MODIFY_DISP)
  	   && post_inc
  	   && try_auto_increment (p, post_inc, post_inc_set, src, newconst, 0))
      post_inc = 0;
*************** fixup_match_1 (insn, set, src, src_subre
*** 3795,3801 ****
    if (post_inc && code == PLUS
    /* Check that newconst is likely to be usable
       in a pre-in/decrement before starting the search.  */
!       && ((HAVE_PRE_INCREMENT && newconst > 0 && newconst <= MOVE_MAX)
  	  || (HAVE_PRE_DECREMENT && newconst < 0 && newconst >= -MOVE_MAX))
        && exact_log2 (newconst))
      {
--- 3844,3851 ----
    if (post_inc && code == PLUS
    /* Check that newconst is likely to be usable
       in a pre-in/decrement before starting the search.  */
!       && (HAVE_PRE_MODIFY_DISP
! 	  || (HAVE_PRE_INCREMENT && newconst > 0 && newconst <= MOVE_MAX)
  	  || (HAVE_PRE_DECREMENT && newconst < 0 && newconst >= -MOVE_MAX))
        && exact_log2 (newconst))
      {


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