Revert "Revert "Optimizing: double-negated bitwise operations simplifications""

This reverts commit 737c0a99dfbba306ec1f50e2adf66b5d97805af6 with fixes.

In the original patch, the new instruction could be inserted before
one of its inputs. A regression test is also added.

Change-Id: Ie49a17ac90ff048355d9cc944b468cd1b1914424
4 files changed