This ports the existing case for G_XOR from getTestBitOperand in AArch64ISelLowering into GlobalISel.
The idea is to flip between TBZ and TBNZ while walking through G_XORs.
Let's say we have
tbz (xor x, c), b
Let's say the b-th bit in c is 1. Then
- If the b-th bit in x is 1, the b-th bit in (xor x, c) is 0.
- If the b-th bit in x is 0, then the b-th bit in (xor x, c) is 1.
So, then
tbz (xor x, c), b == tbnz x, b
Let's say the b-th bit in c is 0. Then
- If the b-th bit in x is 1, the b-th bit in (xor x, c) is 1.
- If the b-th bit in x is 0, then the b-th bit in (xor x, c) is 0.
So, then
tbz (xor x, c), b == tbz x, b