[PATCH] D52286: [Intrinsic] Signed Saturation Intirnsic

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 2 14:52:05 PDT 2018


craig.topper added a comment.

I'm not sure why you would need an intrinsic at all. Why can't you just emit the IR equivalent from the beginning. This looks the equivalent of doing something like "x = std::min(std::max(x, -2048), 2047)" in C++ which would be implemented in IR with 2 compares and 2 selects. This is not an uncommon pattern to find in real code and we spend a lot of effort to make sure its handled well. Adding an intrinsic means you'll miss out on the constant folding, knownbits, etc that we've already put in for min/max IR patterns.

I'm completely in favor of add/sub/mul with saturation intrinsics. I want them to replace the the target specific x86 intrinsics for vector PADDSB/PADDSW/PSUBSB/PSUBSW/etc. I just don't see the need for an intrinsic to just clip the range of a number to a certain number of bits.


Repository:
  rL LLVM

https://reviews.llvm.org/D52286





More information about the llvm-commits mailing list