https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115120
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Tamar Christina from comment #5)
> considering ivopts bails out on doloop prediction for multiple exits anyway,
> what do you think about:
>
> diff --git a/gcc/tree-ssa-loop-ivcanon.cc b/gcc/tree-ssa-loop-ivcanon.cc
> index 5ef24a91917..d1b25ad7dea 100644
> --- a/gcc/tree-ssa-loop-ivcanon.cc
> +++ b/gcc/tree-ssa-loop-ivcanon.cc
> @@ -1319,7 +1319,8 @@ canonicalize_loop_induction_variables (class loop
> *loop,
>
> if (create_iv
> && niter && !chrec_contains_undetermined (niter)
> - && exit && just_once_each_iteration_p (loop, exit->src))
> + && exit && just_once_each_iteration_p (loop, exit->src)
> + && (single_dom_exit (loop) || targetm.predict_doloop_p (loop)))
> {
> tree iv_niter = niter;
> if (may_be_zero)
>
> richi?
I think while IVOPTs might not care, loop-doloop.cc handles multiple exists
just fine I think.
What about moving iv_canon towards iv_optimize? Ideally it would be
integrated with IVOPTs itself, but that can be done later. In particular
I wonder which other passes might depend on iv_canon being run early
(yeah, it also elides single-iteration loops, so maybe you need to "split"
it)