[DAG] PromoteIntRes_ADDSUBSHLSAT - promote ISD::UADDSAT as clamped add
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 16 Feb 2021 17:37:32 +0000 (17:37 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 16 Feb 2021 17:37:44 +0000 (17:37 +0000)
commitdf45c1813509fc579c5e0a4f2824923db92c2dbb
tree6d7d56110505ee90e09102e500185f83f7daab7c
parent07ca13fe0766ded6fd69a6729275020e6b4c0b1b
[DAG] PromoteIntRes_ADDSUBSHLSAT - promote ISD::UADDSAT as clamped add

Similar to D96622, we're better off just promoting uaddsat(x,y) -> umin(add(x,y),c) instead of trying to perform a shifted uaddsat.

I initially tried to just use shifted promotion in cases where we didn't have a legal/custom umin - but we don't appear to have any targets that have uaddsat but not umin, so imo we're better off always using the umin and avoid an untested shifted uaddsat code path.

Differential Revision: https://reviews.llvm.org/D96767
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/test/CodeGen/AArch64/uadd_sat_vec.ll
llvm/test/CodeGen/AMDGPU/uaddsat.ll
llvm/test/CodeGen/X86/uadd_sat_vec.ll