On Fri, 5 Apr 2024, Jan Hubicka wrote: > > + /* When there's a call that might not return the last iteration > > + is possibly partial. This matches what we check in invariant > > + motion. > > + ??? For the call argument evaluation it would be still OK. */ > > + if (!may_have_exited > > + && is_gimple_call (stmt) > > + && gimple_has_side_effects (stmt)) > > + may_have_exited = true; > > I think you are missing here non-call EH, volatile asms and traps. > We have stmt_may_terminate_function_p which tests there.
That returns true for all variable array accesses, I think we want to catch traps explicitly here. I'm going to do if (!may_have_exited && (gimple_has_side_effects (stmt) || stmt_can_throw_external (cfun, stmt))) may_have_exited = true; that should cover all but the generic trapping and not use IPA info to prove no side-effects. Richard. > Honza > > + > > + infer_loop_bounds_from_array (loop, stmt, > > + reliable && !may_have_exited); > > > > - if (reliable) > > + if (reliable && !may_have_exited) > > { > > infer_loop_bounds_from_signedness (loop, stmt); > > infer_loop_bounds_from_pointer_arith (loop, stmt); > > } > > } > > - > > } > > } > > > > @@ -4832,7 +4855,7 @@ estimate_numbers_of_iterations (class loop *loop) > > diagnose those loops with -Waggressive-loop-optimizations. */ > > number_of_latch_executions (loop); > > > > - basic_block *body = get_loop_body (loop); > > + basic_block *body = get_loop_body_in_rpo (cfun, loop); > > auto_vec<edge> exits = get_loop_exit_edges (loop, body); > > likely_exit = single_likely_exit (loop, exits); > > FOR_EACH_VEC_ELT (exits, i, ex) > > -- > > 2.35.3 > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)