This overlaps partially with the codegen patch D144789. This needs nsw for correctness, and I'm not sure if there's an unsigned equivalent:
https://alive2.llvm.org/ce/z/ErmQ-9
This is obviously an improvement in IR, and it looks like a codegen win for all targets and data types that I sampled.
The 'nabs' case is not as clean because I think it would require clearing nsw from the subtract to be correct, so that's left as a potential follow-up (and seems less likely to occur in real code).
It also works for nuw: https://alive2.llvm.org/ce/z/YfWtvG (either op can be either nsw/nuw)