[PATCH] D15385: [Support] Add saturating multiply-add support function

Nathan Slingerland via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 10 10:28:51 PST 2015


slingn added a comment.

In http://reviews.llvm.org/D15385#306733, @silvas wrote:

> > it is probably just slightly more efficient so probably not in this patch.
>
>
> If we are looking to improve efficiency, the clearest improvement to make is to use `__builtin_*_with_overflow` which will dramatically reduce the cost since we can directly use the processor flags instead of using some explicit calculation.


That would be great - and would really simplify the implementation of saturating arithmetic The only caveat is that the __builtin_*_overflow intrinsics aren't supported by every compiler that hosts LLVM. For example, GCC 4.x doesn't have __builtin_add_overflow()  - GCC 5 is required (https://gcc.gnu.org/gcc-5/changes.html). So there would have to be fall-back implementations.


http://reviews.llvm.org/D15385





More information about the llvm-commits mailing list