https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99220
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Created attachment 50245 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50245&action=edit patch So sth like diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 091e727bbc3..24962af903f 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -2351,6 +2351,11 @@ next: { SLP_TREE_REF_COUNT (value)++; SLP_TREE_CHILDREN (root)[i] = value; + /* ??? We know the original leafs of the replaced nodes will + be referenced by bst_map, only the permutes created by + pattern matching are not. */ + if (SLP_TREE_REF_COUNT (node) == 1) + load_map->remove (node); vect_free_slp_tree (node); } } fixes the testcase but not caching load_map across pattern matching will make reasoning this fix is complete easier. Thus I am testing the attached on x86_64-linux, can you test on arm and report back?