This changes the lowering of saddsat and ssubsat so that instead of using
r,o = saddo x, y c = setcc r < 0 s = c ? INTMAX : INTMIN ret o ? s : r
into using asr and xor to materialize the INTMAX/INTMIN constants:
r,o = saddo x, y s = ashr r, BW-1 x = xor s, INTMIN ret o ? x : r
https://alive2.llvm.org/ce/z/TYufgD
This seems to reduce the instruction count in most testcases across most architectures.
We could save two instructions here without really changing the algorithm if we use the carry flag from the adds, i.e. (UADDO LHS, RHS), instead of checking whether the result of the adds is negative. That's the same number of instructions as your new sequence, but with a shorter critical path, so probably better?