https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103218
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- There is code in fold_ternary_loc which does: /* A < 0 ? <sign bit of A> : 0 is simply (A & <sign bit of A>). */ And this works as fold also does (a<0)<<N into (a<0) ? 1<<N : 0 which is not done in match.pd for reasons. We should just handle ((cast)(a < 0)) << signbit in match.pd. Implementing that.