https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85234
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|missed optimisation |missed optimisation |opportunity for (~x >> n) ? |opportunity for (~x >> |a : b with n, a, b |CST)!=0 is not optimized to |constants | (((unsigned)x) < | |~((1<<CST) - 1)) Component|middle-end |tree-optimization --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- int f(int x) { return (~x >> 3) !=0; } int f2(int x) { return (((unsigned)x) < ~((1<<3) - 1)); } The above is what LLVM does really