https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96923
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Created attachment 50905 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50905&action=edit Patch which is in testing (needs testcases) As I said for the case in this PR, it needs https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571616.html too. If you change !b to b; that is "!a ? b : 0", this patch will optimize it. The other patch is needed to allow to move !b out of the conditional.