When running FRE in the loop pipeline (as part of the conditionally
scheduled scalar cleanups) we have to reset the SCEV hashtable as
otherwise we can end up with stale entries and all sorts of problems.

Catched by my out-of-tree verifier for this problem.

Bootstrap & regtest pending on x86_64-unknown-linux-gnu.

2021-01-08  Richard Biener  <rguent...@suse.de>

        * tree-ssa-sccvn.c (pass_fre::execute): Reset the SCEV hash table.
---
 gcc/tree-ssa-sccvn.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 17016853a34..0ba846f0be2 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -7883,6 +7883,9 @@ pass_fre::execute (function *fun)
   if (iterate_p)
     loop_optimizer_finalize ();
 
+  if (scev_initialized_p ())
+    scev_reset_htab ();
+
   /* For late FRE after IVOPTs and unrolling, see if we can
      remove some TREE_ADDRESSABLE and rewrite stuff into SSA.  */
   if (!may_iterate)
-- 
2.26.2

Reply via email to