https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71336
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #10) > So it should be possible to extend the match pattern for what was the > two_value_replacement replacement to do this too. > The main thing is instead of difference by 1, the difference of the two > constants should be a power of 2. > We could also extend it such that the (a !=/== CST) part where a has only > one non-zero bit in addition to a having a range over two values. > > That would be better than what I was proposing in comment #6. Actually we already have a pattern for: (zero_one == 0) ? y : z <op> y (zero_one != 0) ? z <op> y : y Just in this case y and z are constant. And the mention of one bit set for a in `a != 0` has been mentioned in one places too ...