FR: Compile “−x − 1” as “not x”.

...Preferably even regardless of the overflow checks (at least with signed x, as in this case -x - 1 always fits into the type of x).

For example, it is occasionally useful to pack a boolean flag and an (N−1)-bit unsigned integer into one N-bit signed number x, where:

  • x >= 0 represents true flag and source number x;

  • x < 0 represents false flag and source number -x - 1, more efficiently but less intuitively calculated as not x.

GCC seems to do it on sight, emitting not even at -O0.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information