[llvm-commits] [PATCH] UINT_TO_FP of vectors

Rotem, Nadav nadav.rotem at intel.com
Thu Mar 17 01:38:17 PDT 2011


Steve, Dirk, 

Thanks for the review of the patch. I have experimented with two types of conversions:

1. Conversion using two SINT_TO_FP on 16bit components [1].
2. Conversion using a single SINT_TO_FP and adjustment of the sign bit [2]. 

In the patch I have implemented the first method. ICC and GCC use the second method. The second method is indeed faster, but I noticed that it is not accurate enough in some cases. I worked under the assumption that UINT_TO_FP needs to be IEEE-accurate.

Nadav

[1] - http://developer.apple.com/hardwaredrivers/ve/sse.html#Translation_Conv_F2I

[2] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40811


-----Original Message-----
From: Stephen Canon [mailto:scanon at apple.com] 
Sent: Thursday, March 17, 2011 00:41
To: Dirk Steinke
Cc: Rotem, Nadav; llvm-commits at cs.uiuc.edu
Subject: Re: [llvm-commits] [PATCH] UINT_TO_FP of vectors

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
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.





More information about the llvm-commits mailing list