int f(int x) { return ~(~x & (~x - 1)); } This can be optimized to `return (x + 1) | x;`. This transformation is done by LLVM, but not by GCC.
We already transform to return ~(-2 - x) | x; so this is really asking for ~(-2 - x) --> x + 1
Better test case (I'd assume) : int f(int x) { return ~(constant - x); } which should be optimizable to `x + ~constant`.
MIne because this is basically PR 37516.
Fixed with r11-5958.