https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86489
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- gimple *phi = SSA_NAME_DEF_STMT (b_11); if (gimple_code (phi) != GIMPLE_PHI || (gimple_assign_lhs (and_stmt) != gimple_phi_arg_def (phi, loop_latch_edge (loop)->dest_idx))) return false; this may fail if the PHI in question is not the correct one in which case it may not have the argument at the latch dest_idx. Try first verifying that the loop latch destination is indeed gimple_bb (phi).