summaryrefslogtreecommitdiff
path: root/gcc/loop.c
diff options
context:
space:
mode:
authorwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>1998-04-07 12:00:13 +0000
committerwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>1998-04-07 12:00:13 +0000
commitc8e5b8a3518de267e3c6b9f6e022e57f18c15481 (patch)
tree097a5f58a110cf49bf93bd68109e7ea43318ed76 /gcc/loop.c
parent2af98c0dd462339634f41aec9700ba8f8d35f12e (diff)
downloadgcc-c8e5b8a3518de267e3c6b9f6e022e57f18c15481.tar.gz
Fix loop reversal bug reported by Joern Rennecke.
* loop.c (check_dbra_loop): When normalize comparison_val, add check to verify it is non-negative. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@19030 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/loop.c')
-rw-r--r--gcc/loop.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/loop.c b/gcc/loop.c
index d46ca648834..a3f7a8f59bc 100644
--- a/gcc/loop.c
+++ b/gcc/loop.c
@@ -6281,7 +6281,10 @@ check_dbra_loop (loop_end, insn_count, loop_start)
&& GET_CODE (initial_value) == CONST_INT)
{
comparison_val = comparison_val - INTVAL (bl->initial_value);
- initial_value = const0_rtx;
+ /* 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