[PATCH] D54749: Saturating float to int casts.

John McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 11:44:08 PDT 2020


rjmccall added a comment.

I can't competently review LLVM code-gen patches, but I can review intrinsic design.  If the intended use case here is fixed point, should there be a scale parameter rather than expecting the caller to scale the input?  Or is scaling the input basically the expected implementation on all hardware?  Scaling the input can be lossy if we overflow to infinity, so that would be making a tacit assumption here that if that happens, the original value must've been outside the representation range of the integer.  For `float` (and `bfloat`), the exponent goes up to 127, so you would need to be converting to a pretty large fixed-point format to have problems with lossy overflow.  For `half`, the exponent only goes up to 16, so converting to a 32-bit fixed-point format with a scale could overflow, and you probably won't be able to use these intrinsics.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54749/new/

https://reviews.llvm.org/D54749



More information about the llvm-commits mailing list