This is the mail archive of the gcc@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: x86 failure on loop reversal


The existing test is (FOO >= 0).  Changing that to an unsigned test doesn't
look very useful, as it will be always true.  I suggest we just avoid
reversing the loop in this case.  This is rare enough, and tricky enough,
that I don't think we need to handle it.

How about something like this?  If this is OK, I will add the testcase and
check in the patch at the same time.

Mon Apr  6 20:08:43 1998  Jim Wilson  <wilson@cygnus.com>

	* loop.c (check_dbra_loop): When normalize comparison_val, add check
	to verify it is non-negative.

Index: loop.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/loop.c,v
retrieving revision 1.37
diff -p -r1.37 loop.c
*** loop.c	1998/03/25 10:32:36	1.37
--- loop.c	1998/04/07 03:06:43
*************** check_dbra_loop (loop_end, insn_count, l
*** 6281,6287 ****
  		  && GET_CODE (initial_value) == CONST_INT)
  		{
  		  comparison_val = comparison_val - INTVAL (bl->initial_value);
! 		  initial_value = const0_rtx;
  		}
  
  	      /* If the initial value is not zero, or if the comparison
--- 6281,6290 ----
  		  && GET_CODE (initial_value) == CONST_INT)
  		{
  		  comparison_val = comparison_val - INTVAL (bl->initial_value);
! 		  /* Check for overflow.  If comparison_val ends up as a
! 		     negative value, then we can't reverse the loop.  */
! 		  if (comparison_val >= 0)
! 		    initial_value = const0_rtx;
  		}
  
  	      /* If the initial value is not zero, or if the comparison


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