https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98212
--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> --- f1 is currently unoptimal by design, the compiler is unable to merge trapping and non-trapping instructions. There is already a PR for that. f2 is not optimal. The conditional jump to the unconditional jump can be merged, but the compiler currently does not perform that optimization.