https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69466
--- Comment #5 from Alexandre Oliva <aoliva at gcc dot gnu.org> --- Created attachment 37486 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37486&action=edit Patch I'm testing to fix the problem The problem occurs because we call set_current_def for phi nodes after duplicating some blocks, but it isn't always the case that the blocks passed to slpeel_duplicate_current_defs_from_edges were copied from one another. In the given testcase, the exit blocks passed to this function don't seem to be related at all, so taking information from corresponding phi nodes to call set_current_def is most certainly incorrect. Indeed, it's calling set_current_def for a virtual operand from a "corresponding" non-virtual operand that causes slpeel_duplicate_current_defs_from_edges's use of get_current_def to set up an incorrect, non-virtual value for the virtual-operand phi node. With this patch, we refrain from setting current defs when blocks don't have analogous phi nodes, and this is enough to address the problem. It would be nice, however, if someone more familiar with the loop vectorizer would check whether our calling this function with mismatched blocks indicates another latent problem, or whether we could check for the mismatch and bypass the call more efficiently at the caller. For this testcase, the mismatching call is the single_exit (scalar_loop) one in slpeel_tree_duplicate_loop_to_edge_cfg.