From 490862aa5523e93b2b7c2946ed6898d3400d075a Mon Sep 17 00:00:00 2001
From: hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 18 Jan 2007 21:58:18 +0000
Subject: [PATCH] 	* tree-ssa-operands.c (vop_free_bucket_size): Never
 return value 	greater than NUM_VOP_FREE_BUCKETS.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120933 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog           |  5 +++++
 gcc/tree-ssa-operands.c | 12 +++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 983e3d9dcbf4..68fe46565601 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-18  Jan Hubicka  <jh@suse.cz>
+
+	* tree-ssa-operands.c (vop_free_bucket_size): Never return value
+	greater than NUM_VOP_FREE_BUCKETS.
+
 2007-01-18  Daniel Berlin  <dberlin@dberlin.org>
 
 	* tree-ssa-structalias.c: Update comments.
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index 23e493a2b04f..0006de924493 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -305,15 +305,17 @@ vop_free_bucket_size (int bucket)
 static inline int 
 vop_free_bucket_index (int num)
 {
-  gcc_assert (num > 0);
+  gcc_assert (num > 0 && NUM_VOP_FREE_BUCKETS > 16);
 
   /* Sizes 1 through 16 use buckets 0-15.  */
   if (num <= 16)
     return num - 1;
-  /* Buckets 16 - 45  represent 17 through 256 in 8 unit chunks.  */
-  if (num < 256)
-    return 14 + (num - 1) / 8;
-  return -1;
+  /* Buckets 16 - NUM_VOP_FREE_BUCKETS represent 8 unit chunks.  */
+  num = 14 + (num - 1) / 8;
+  if (num >= NUM_VOP_FREE_BUCKETS)
+    return -1;
+  else
+    return num;
 }
 
 
-- 
GitLab