https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102809
--- Comment #1 from Aldy Hernandez <aldyh at gcc dot gnu.org> --- There's a pending patch in this area that restricts loop threading: https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581894.html Does this fix the problem?