[GlobalISel][AMDGPU] Legalize saturating add/subtract
authorJay Foad <jay.foad@amd.com>
Sun, 12 Jul 2020 18:18:45 +0000 (14:18 -0400)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 23 Jul 2020 13:06:42 +0000 (09:06 -0400)
commitb35833b84e95c42ca7166232e193b2b8e221b56a
tree33ff0d9f0832fc207f5398ae5b72af854bf3e087
parent82e35197e68311abf7561f9ed05fbfc09be0e601
[GlobalISel][AMDGPU] Legalize saturating add/subtract

Add support in LegalizerHelper for lowering G_SADDSAT etc. either
using add/subtract-with-overflow or using max/min instructions.

Enable this lowering for AMDGPU so it can be tested. The legalization
rules are still approximate and skips out on using the clamp bit to
treat these as legal, which has never been used before. This also
doesn't yet try to deal with expanding SALU cases.
13 files changed:
llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-saddsat.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-ssubsat.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-uaddsat.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-usubsat.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/saddsat.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/GlobalISel/ssubsat.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/GlobalISel/uaddsat.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/GlobalISel/usubsat.ll [new file with mode: 0644]