This code is directly ported from the X86 backend which applies the same rewrite (along with several others). As noted in the test change, we are missing a canonicalization or inversion of this pattern for the != 1 case. Plan to address in following change. Also planning on looking more closely at the other branchless variants from x86 to see if any are worth porting.
Motivation here is the coremark crc8 routine from https://github.com/eembc/coremark/blob/main/core_util.c#L165. This patch significantly reduces the number of unpredictable branches in the workload.
Use ISD::isIntEqualitySetCC(CCVal)?