Add/test optimization: reduce cmp to equality when possible