[Mesa-stable] [Mesa-dev] [PATCH] llvmpipe: convert double to long long instead of unsigned long long

Jose Fonseca jfonseca at vmware.com
Fri Sep 4 04:43:41 PDT 2015


On 03/09/15 16:26, Tom Stellard wrote:
> On Thu, Sep 03, 2015 at 06:15:26PM +0300, Oded Gabbay wrote:
>> round(val*dscale) produces a double result, as val and dscale are double.
>> However, LLVMConstInt receives unsigned long long, so there is an
>> implicit conversion from double to unsigned long long.
>> This is an undefined behavior. Therefore, we need to first explicitly
>> convert the round result to long long, and then let the compiler handle
>> conversion from that to unsigned long long.
>>
>> This bug manifests itself in POWER, where all IMM values of -1 are being
>> converted to 0 implicitly, causing a wrong LLVM IR output.
>>
>
>> Signed-off-by: Oded Gabbay <oded.gabbay at gmail.com>
>> CC: "10.6" <mesa-stable at lists.freedesktop.org>
>> ---
>
> You should add 11.0 to the CC too.
>
> This patch is:
> Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
>
> But I wonder why this function is being used for an integer value in the
> first place.

This is used when representing constants like 1.0 with unorms/snorms. 
The caller says, give me the unorm8 equivalent of 1.0, and this function 
will return 255.

In short, the input is the intended value, the output is the actual 
representation.

Jose


More information about the mesa-stable mailing list