This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Is this a bug in doloop.c?
- From: John Lu <jlu at lsil dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 25 Aug 2004 15:03:42 -0500 (CDT)
- Subject: Is this a bug in doloop.c?
- Reply-to: John Lu <jlu at lsil dot com>
Hi,
I'm working on a port based on gcc-3.4.1, and I'm
trying to use the doloop_end pattern. In doloop.c:440-469,
the exit test generated by this pattern is analyzed in order to determine
how to initialize the looping register. This code sets a variable,
decrement_count, if the looping register needs to be set to N-1,
in order for the loop to iterate N times. Currently, if the
exit test is:
(if_then_else (ge (match_operand:QI 0 "register_operand" "")
(const_int 0))
the looping register is set to N-1. But shouldn't this be done only
if the test is:
(if_then_else (ge (match_operand:QI 0 "register_operand" "")
(const_int 1))
The relevant code from doloop.c is:
decrement_count = 0;
switch (GET_CODE (condition))
{
case NE:
/* Currently only NE tests against zero and one are supported. */
if (XEXP (condition, 1) == const0_rtx)
decrement_count = 1;
else if (XEXP (condition, 1) != const1_rtx)
abort ();
break;
case GE:
/* Currently only GE tests against zero are supported. */
==> if (XEXP (condition, 1) != const0_rtx)
abort ();
/* The iteration count needs decrementing for a GE test. */
decrement_count = 1;
...
I believe in the marked line, const0_rtx should be replaced const1_rtx.
Thanks,
John Lu