[PATCH] D59006: [x86] improve the default expansion of uaddsat/usubsat

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 5 16:13:55 PST 2019


spatel created this revision.
spatel added reviewers: nikic, craig.topper, RKSimon, lebedev.ri.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.

This is yet another step towards solving PR14613 (almost there!):
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.

There may be some small AVX1 opportunities still lurking, but I saw regressions if we allow those transforms wholesale, so stopping here to make sure things look right/better.


https://reviews.llvm.org/D59006

Files:
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59006.189414.patch
Type: text/x-patch
Size: 77010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190306/771ed85d/attachment.bin>


More information about the llvm-commits mailing list