https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90231
--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Note, there already is a function that is meant to handle this, remove_unused_ivs, just either it doesn't find the right IV candidate, or get_computation_at fails. On this particular testcase, I see 2 IVs in the code originally, with the PHI results base_17 and i_18, and two IVs in the code afterwards, base_17 and ivtmp.11_20. remove_unused_ivs for i_18 decides the best candidate is base_17, which is unsigned int IV with step 15, so I'd guess the problem we've discussed happens for that one. That base_17 cand has cand_pref of 2, while the ivtmp.11_20 one has cand_pref of 0 and so base_17 wins. Anyway, just trying to pass the other cand to get_computation_at fails too. Why?