This teaches tryOptSelect to handle folding G_ICMP, and removes the requirement that the G_SELECT we're dealing with is floating point.
Some refactoring to make this work nicely as well:
- Factor out the scalar case from the selection code for G_ICMP into emitIntegerCompare.
- Make tryOptCMN return a MachineInstr* instead of a bool.
- Make tryOptCMN not modify the instruction being selected.
- Factor out the CMN emission into emitCMN for readability.
By doing this this way, we can get all of the compare selection optimizations in select emission.
This looks incorrect ( && has higher precedence than || ). So I assume it should be
And we get a warning when building with gcc:
../lib/Target/AArch64/AArch64InstructionSelector.cpp:2938:48: error: suggest parentheses around '&&' within '||' [-Werror=parentheses]
assert(CmpTy.isScalar() || CmpTy.isPointer() && "Expected scalar or pointer");