Unsigned CCCondCode Legalization


Currently, if a target cannot perform unsigned comparisons the
legalizer will hit a llvm_unreachable. This is easily achieved by
telling the legalizer to expand all unsigned condcodes.

setCondCodeAction(ISD::SETUxx, MVT::ixx, Expand);

This is because in SelectionDAGLegalize::LegalizeSetCCCondCode it will
only attempt to invert an operation and not any other expansions.

To convert from an unsigned integer operation to a singed one whilst
still keeping the same result, zero extending to iN + 1 and removing
the unsigned flag from the CCCode should be enough (as far as I can

I was wondering if this type of expansion purposefully was not
implemented (and if I'm missing something obvious), or if it is worth
writing a patch for this.



This won’t work. You would always need to have a wider, legal integer type available. Since condition codes are legalized after type legalization, you must expand them in terms of operations on legal types