[llvm-commits] [PATCH] UINT_TO_FP of vectors

Stephen Canon scanon at apple.com
Wed Mar 16 15:40:39 PDT 2011


On Mar 16, 2011, at 3:29 PM, Dirk Steinke wrote:

[snip]
>  SINT_TO_FP(high 31 bits) * (2) + SINT_TO_FP(low 1 bit)

This actually suffers from the same problem; 0x81000081 rounds to 0x81000000 instead of 0x81000100 as it should.

In order to work properly, an int->float conversion needs to consist of a sum of two values, both of which are guaranteed to have been converted without rounding.  There are tricks (sticky bits) that can be used to simplify this somewhat in more extreme cases (like uint64_t -> float), but generally you need each of the components to be built from fewer bits than the precision of the floating-point type.

- Steve



More information about the llvm-commits mailing list