https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84086
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Released by
#0 release_ssa_name_fn (fn=0x7ffff6a5f160, var=<ssa_name 0x7ffff6a8c9d8>)
at /space/rguenther/src/svn/early-lto-debug/gcc/tree-ssanames.c:536
#1 0x00000000013735fe in release_ssa_name (name=<ssa_name 0x7ffff6a8c9d8>)
at /space/rguenther/src/svn/early-lto-debug/gcc/tree-ssanames.h:141
#2 0x0000000001376b5c in release_defs (stmt=<gimple_call 0x7ffff6a716c0>)
at /space/rguenther/src/svn/early-lto-debug/gcc/tree-ssanames.c:826
#3 0x00000000013f6081 in adjust_simduid_builtins (htab=0x0)
at /space/rguenther/src/svn/early-lto-debug/gcc/tree-vectorizer.c:237
#4 0x00000000013f7a49 in vectorize_loops ()
at /space/rguenther/src/svn/early-lto-debug/gcc/tree-vectorizer.c:839
but that doesn't clear the SCEV cache. [I still think maintaining this
cache over pass boundaries is a ticking bomb... we eventually should add
a verifier that walks the hashtable looking for released SSA names - but
that's not the only issue with the cache obviously!]
So here we're coming via
1416 if (!simple_iv (loop, loop_containing_stmt (stmt), lhs, iv, true))
1417 return false;
of said stmt and get at the initial SCEV via the cache which was built when
the stmt was still _14 = _21;
So a slightly more generic fix than putting a scev_reset into the vectorizer
would be
Index: gcc/tree-ssanames.c
===================================================================
--- gcc/tree-ssanames.c (revision 257139)
+++ gcc/tree-ssanames.c (working copy)
@@ -29,6 +29,8 @@ along with GCC; see the file COPYING3.
#include "stor-layout.h"
#include "tree-into-ssa.h"
#include "tree-ssa.h"
+#include "cfgloop.h"
+#include "tree-scalar-evolution.h"
/* Rewriting a function into SSA form can create a huge number of SSA_NAMEs,
many of which may be thrown away shortly after their creation if jumps
@@ -241,6 +243,9 @@ verify_ssaname_freelists (struct functio
void
flush_ssaname_freelist (void)
{
+ /* If there were any SSA names released reset the SCEV cache. */
+ if (! vec_safe_is_empty (FREE_SSANAMES_QUEUE (cfun)))
+ scev_reset_htab ();
vec_safe_splice (FREE_SSANAMES (cfun), FREE_SSANAMES_QUEUE (cfun));
vec_safe_truncate (FREE_SSANAMES_QUEUE (cfun), 0);
}