[tuples] Fix bootstrap on 64 bit hosts
Jakub Jelinek
jakub@redhat.com
Tue Jul 1 12:23:00 GMT 2008
On Wed, Jun 25, 2008 at 09:21:19AM -0400, Diego Novillo wrote:
> tree-vectorizer.c:hash_gimple_stmt was casting 64bit pointers to 32bit
> ints. Fixed by using htab_hash_pointer instead.
> 2008-06-25 Diego Novillo <dnovillo@google.com>
>
> * tree-vectorizer.c (hash_gimple_stmt): Remove.
> (eq_gimple_stmt): Remove.
> (init_stmt_vec_info_htab): Use htab_hash_pointer and
> htab_eq_pointer for STMT_VEC_INFO_HTAB.
This looks wrong. gimple will never be equal to stmt_vec_info, so this
htab acts as a write-only hashtab - every lookup will return a new slot,
as htab_eq_pointer will always return false.
Either we can use a pointer_map, or, given that we have
STMT_VINFO_STMT in stmt_vec_info, we can do following. Note even
storing NULL info the htable slot was incorrect.
2008-07-01 Jakub Jelinek <jakub@redhat.com>
* tree-vectorizer.h (vinfo_for_stmt): Use htab_find_slot_with_hash.
(set_vinfo_for_stmt): Likewise. If info is NULL, delete entry from
hash table.
* tree-vectorizer.c (stmt_vec_info_eq, stmt_vec_info_hash): New
functions.
(init_stmt_vec_info_htab): Use them instead of htab_hash_pointer
and htab_eq_pointer.
--- gcc/tree-vectorizer.c.jj 2008-06-27 18:54:54.000000000 +0200
+++ gcc/tree-vectorizer.c 2008-07-01 11:54:34.000000000 +0200
@@ -1566,6 +1566,19 @@ new_stmt_vec_info (gimple stmt, loop_vec
return res;
}
+static int
+stmt_vec_info_eq (const void *p1, const void *p2)
+{
+ return (const_gimple) STMT_VINFO_STMT ((const struct _stmt_vec_info *) p1)
+ == (const_gimple) p2;
+}
+
+static hashval_t
+stmt_vec_info_hash (const void *p)
+{
+ const struct _stmt_vec_info *i = (const struct _stmt_vec_info *) p;
+ return htab_hash_pointer (STMT_VINFO_STMT (i));
+}
/* Create a hash table for stmt_vec_info. */
@@ -1573,7 +1586,7 @@ void
init_stmt_vec_info_htab (void)
{
gcc_assert (!stmt_vec_info_htab);
- stmt_vec_info_htab = htab_create (10, htab_hash_pointer, htab_eq_pointer,
+ stmt_vec_info_htab = htab_create (10, stmt_vec_info_hash, stmt_vec_info_eq,
NULL);
}
--- gcc/tree-vectorizer.h.jj 2008-06-27 18:54:54.000000000 +0200
+++ gcc/tree-vectorizer.h 2008-07-01 12:06:42.000000000 +0200
@@ -531,7 +531,8 @@ static inline stmt_vec_info
vinfo_for_stmt (gimple stmt)
{
void **slot;
- slot = htab_find_slot (stmt_vec_info_htab, stmt, NO_INSERT);
+ slot = htab_find_slot_with_hash (stmt_vec_info_htab, stmt,
+ htab_hash_pointer (stmt), NO_INSERT);
return slot ? (stmt_vec_info) *slot : NULL;
}
@@ -539,9 +540,20 @@ static inline void
set_vinfo_for_stmt (gimple stmt, stmt_vec_info info)
{
void **slot;
- slot = htab_find_slot (stmt_vec_info_htab, stmt, INSERT);
- gcc_assert (!(*slot && info));
- *slot = info;
+ if (info)
+ {
+ slot = htab_find_slot_with_hash (stmt_vec_info_htab, stmt,
+ htab_hash_pointer (stmt), INSERT);
+ gcc_assert (!*slot);
+ *slot = info;
+ }
+ else
+ {
+ slot = htab_find_slot_with_hash (stmt_vec_info_htab, stmt,
+ htab_hash_pointer (stmt), NO_INSERT);
+ if (slot)
+ htab_clear_slot (stmt_vec_info_htab, slot);
+ }
}
static inline bool
Jakub
More information about the Gcc-patches
mailing list