options: use cl_optimization_hash.

Message ID ecd24a6e-e716-6648-6134-798a0278a15d@suse.cz
State New
Headers
Series options: use cl_optimization_hash. |

Commit Message

Martin Liška Oct. 8, 2021, 10:23 a.m. UTC
  Hello.

Right now, we use legacy hashing function in cl_option_hasher and I also
need the change for the future fix of PR102585.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

	* tree.c (cl_option_hasher::hash): Use cl_optimization_hash
	and remove legacy hashing code.
---
  gcc/tree.c | 19 +------------------
  1 file changed, 1 insertion(+), 18 deletions(-)
  

Comments

Martin Liška Oct. 11, 2021, 7:56 a.m. UTC | #1
On 10/8/21 12:23, Martin Liška wrote:
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

I've spoken to Honza and he approves the patch.
I'm going to install it.

Martin
  

Patch

diff --git a/gcc/tree.c b/gcc/tree.c
index 561b9cd56bd..7bfd64160f4 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -11473,30 +11473,13 @@  hashval_t
  cl_option_hasher::hash (tree x)
  {
    const_tree const t = x;
-  const char *p;
-  size_t i;
-  size_t len = 0;
-  hashval_t hash = 0;
  
    if (TREE_CODE (t) == OPTIMIZATION_NODE)
-    {
-      p = (const char *)TREE_OPTIMIZATION (t);
-      len = sizeof (struct cl_optimization);
-    }
-
+    return cl_optimization_hash (TREE_OPTIMIZATION (t));
    else if (TREE_CODE (t) == TARGET_OPTION_NODE)
      return cl_target_option_hash (TREE_TARGET_OPTION (t));
-
    else
      gcc_unreachable ();
-
-  /* assume most opt flags are just 0/1, some are 2-3, and a few might be
-     something else.  */
-  for (i = 0; i < len; i++)
-    if (p[i])
-      hash = (hash << 4) ^ ((i << 2) | p[i]);
-
-  return hash;
  }
  
  /* Return nonzero if the value represented by *X (an OPTIMIZATION or