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

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 10 15:22:33 PST 2015


silvas added a comment.

In http://reviews.llvm.org/D15385#307298, @slingn wrote:

> 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.


Yeah, it would require some ifdef's and would be extra work. Like I said, "if" we are looking to improve efficiency. I don't think this code at the moment has been measured to be a perf problem though. Also, for PS4, our shipping toolchain is currently compiled with MSVC so this would not affect us anyway (if we used clang-cl, then we could use the __builtin_*_overflow intrinsics, but while clang-cl would be great, I don't think we are planning to do that soon).


http://reviews.llvm.org/D15385





More information about the llvm-commits mailing list