https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115579
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So looking into the code. The problem is the ordering. That is if the store to b is first things will just work. The loop to call execute_sm: execute_sm (loop, ref, aux_map, true, !first_p); Except use_other_flag_var is wrong if the first one didn't have a store flag. if (multi_threaded_model_p && !use_other_flag_var) aux->store_flag = execute_sm_if_changed_flag_set (loop, ref, &aux->flag_bbs); else aux->store_flag = NULL_TREE;