I am interested in finding a Boolean/arithmetic function that will return -1 if two values match, and 0 if they do not match, in other words the == operation. I know this can be done with a logical NOT, for example:
! (A-B)
which will be -1 (= 111111111.... in binary) if A == B. But the problem is that this compiles to a big right shift, like >> 31
which is expensive. I was hoping to find short cycle binary instructions that could achieve the same effect.
How does == compile when used as an R-value, same way as !(A-B)?