[PATCH] D44909: [DAGCombine] (float)((int) f) --> ftrunc (PR36617)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 12 09:00:53 PDT 2018


spatel added a comment.

In https://reviews.llvm.org/D44909#1065786, @efriedma wrote:

> > After this change, is there some way to express this approach in C?
>
> You can use platform-specific intrinsics, e.g. _mm_cvtsd_si32 is defined to return INT_MIN for out-of-range values.  Or, in portable C, you can do a range check: `if (x <= INT_MAX && x >= INT_MIN && (double)(int)x == x)`.


C++ (templated) option is shown as an example here:
https://stackoverflow.com/questions/2544394/c-floating-point-to-integer-type-conversions


Repository:
  rL LLVM

https://reviews.llvm.org/D44909





More information about the llvm-commits mailing list