[x86] improve the default expansion of uaddsat/usubsat
authorSanjay Patel <spatel@rotateright.com>
Sun, 24 Mar 2019 13:55:54 +0000 (13:55 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sun, 24 Mar 2019 13:55:54 +0000 (13:55 +0000)
commit7d676dfd86fa9192a34983de14978d453d6e4638
treed669da93e80d2a28f4723514fbfafe8eed4e7464
parent5cd4eb96f651ef5b6306ef73835a2da59f63c8cc
[x86] improve the default expansion of uaddsat/usubsat

This is yet another step towards solving PR14613:
https://bugs.llvm.org/show_bug.cgi?id=14613

uaddsat X, Y --> (X >u (X + Y)) ? -1 : X + Y
usubsat X, Y --> (X >u Y) ? X - Y : 0

We can't count on a sane vector ISA, so override the default (umin/umax)
expansion of unsigned add/sub saturate in cases where we do not have umin/umax.

Differential Revision: https://reviews.llvm.org/D59006

llvm-svn: 356855
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/uadd_sat.ll
llvm/test/CodeGen/X86/uadd_sat_vec.ll
llvm/test/CodeGen/X86/usub_sat.ll
llvm/test/CodeGen/X86/usub_sat_vec.ll