https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99954
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> using -O2 "fixes" the issue on GCC 9 and below but not on 10.
And that changed with r271553
PR tree-optimization/88440
* opts.c (default_options_table): Enable
-ftree-loop-distribute-patterns
at -O[2s]+.
* tree-loop-distribution.c (generate_memset_builtin): Fold the
generated call.
(generate_memcpy_builtin): Likewise.
(distribute_loop): Pass in whether to only distribute patterns.
(prepare_perfect_loop_nest): Also allow size optimization.
(pass_loop_distribution::execute): When optimizing a loop
nest for size allow pattern replacement.