[InstCombine] fold sub-of-umax to 0-usubsat
authorSanjay Patel <spatel@rotateright.com>
Tue, 9 Nov 2021 17:31:15 +0000 (12:31 -0500)
committerSanjay Patel <spatel@rotateright.com>
Tue, 9 Nov 2021 17:46:03 +0000 (12:46 -0500)
commit2a88d00cf250534f31c706bc832f0f6386c28ef3
tree3d03117cdd1ca3965a10eeda27523cf26bb1385a
parentde12ca31d477d4a5f6c5d84504eb99f54e7dc2dc
[InstCombine] fold sub-of-umax to 0-usubsat

Op0 - umax(X, Op0) --> 0 - usub.sat(X, Op1)

I'm not sure if this is really an improvement in IR because
we probably have better recognition/analysis for min/max,
but this lines up with the fold we do for the icmp+select
idiom and removes another diff from D98152.

This is similar to the previous fold in the code that was
added with:
83c2fb9f66be
baa6a851308d

https://alive2.llvm.org/ce/z/5MrVB9
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/sub-minmax.ll