https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121338
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:7d66563e8152360a298dd1dcfe09491853db7f03 commit r16-2704-g7d66563e8152360a298dd1dcfe09491853db7f03 Author: Richard Biener <rguent...@suse.de> Date: Fri Aug 1 08:55:11 2025 +0200 tree-optimization/121338 - UBSAN error in adjust_setup_cost The following avoids possibly overflowing adds for rounding. We know cost is bound, so it's enough to do this simple test. PR tree-optimization/121338 * tree-ssa-loop-ivopts.cc (avg_loop_niter): Return an unsigned. (adjust_setup_cost): When niters is so large the division result is one or zero avoid it. (create_new_ivs): Adjust.