We can invert a compare constant and compare predicate and preserve the logic as shown in this sampling:
https://alive2.llvm.org/ce/z/YAXbfs
(In theory, we could deal with non-all-ones/zero as well, but it doesn't seem worthwhile.)
I noticed this as a part of the x86 codegen difference in https://llvm.org/PR51259 - that ends up using "test" instead of "not + cmp" in that example.
This pattern also shows up in https://llvm.org/PR41312 and https://llvm.org/PR50798 .