Fold select_cc x, 0, const0, const1, lt into sub (z, and ((sra x, sizeof(x)-1), z - y)), see https://alive2.llvm.org/ce/z/jqcf8t. On PPC, it's cheap to performance such optimization with rlwinm.
|2790 ↗||(On Diff #311484)|
We need to determine whether other targets would benefit from this - otherwise I'd suggest the initial implementation was purely inside PPCISelLowering
I don't think it's always profitable. I've updated the comment to make it clearer. The transformation involves in arithmetic shift and SIGN_EXTEND looks not zero overhead under some circumstances.