On Thu, Sep 3, 2015 at 6:26 PM, Tom Stellard <[email protected]> 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 <[email protected]>
>> CC: "10.6" <[email protected]>
>> ---
>
> You should add 11.0 to the CC too.
>
> This patch is:
> Reviewed-by: Tom Stellard <[email protected]>
>
Thanks, I will re-send the patch.

> But I wonder why this function is being used for an integer value in the
> first place.
>
> -Tom
The shader defines an immediate vector, so It is called from lp_build_const_vec

          Oded

>
>>  src/gallium/auxiliary/gallivm/lp_bld_const.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.c 
>> b/src/gallium/auxiliary/gallivm/lp_bld_const.c
>> index 0f5a8f8..9cd7c55 100644
>> --- a/src/gallium/auxiliary/gallivm/lp_bld_const.c
>> +++ b/src/gallium/auxiliary/gallivm/lp_bld_const.c
>> @@ -311,7 +311,7 @@ lp_build_const_elem(struct gallivm_state *gallivm,
>>     else {
>>        double dscale = lp_const_scale(type);
>>
>> -      elem = LLVMConstInt(elem_type, round(val*dscale), 0);
>> +      elem = LLVMConstInt(elem_type, (long long) round(val*dscale), 0);
>>     }
>>
>>     return elem;
>> --
>> 2.4.3
>>
>> _______________________________________________
>> mesa-dev mailing list
>> [email protected]
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-stable mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/mesa-stable
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to