This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: x86 failure on loop reversal
- To: Joern Rennecke <amylaar at cygnus dot co dot uk>
- Subject: Re: x86 failure on loop reversal
- From: Jim Wilson <wilson at cygnus dot com>
- Date: Mon, 06 Apr 1998 20:10:05 -0700
- cc: tege at pdc dot kth dot se (Torbjorn Granlund), law at cygnus dot com, egcs at cygnus dot com
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