[Mesa-dev] [PATCH] nvc0/lowering: Handle conversions to U64/S64 manually
Hans de Goede
hdegoede at redhat.com
Mon Apr 18 09:21:31 UTC 2016
Hi,
On 17-04-16 22:27, Pierre Moreau wrote:
> On 04:17 PM - Apr 17 2016, Ilia Mirkin wrote:
>> On Sun, Apr 17, 2016 at 4:07 PM, Pierre Moreau <pierre.morrow at free.fr> wrote:
>>> Ping :-)
>>>
>>> On 10:56 PM - Mar 19 2016, Pierre Moreau wrote:
>>>> Generating a `cvt u32 $r0 u64 $r1d` or a `cvt u64 $r0d u32 $r2` makes the GPU
>>>> unhappy. Instead, manually handle the conversion between 64-bit and 32-bit
>>>> values, and use `cvt` to convert between the original target (resp. source)
>>>> and 32-bit value. This happens to be the behaviour of NVIDIA's driver.
>>>>
>>>> Signed-off-by: Pierre Moreau <pierre.morrow at free.fr>
>>>> ---
>>>> .../nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 59 ++++++++++++++++++++++
>>>> .../nouveau/codegen/nv50_ir_lowering_nvc0.h | 1 +
>>>> 2 files changed, 60 insertions(+)
>>>>
>>>> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
>>>> index 2719f2c..c419a68 100644
>>>> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
>>>> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
>>>> @@ -1859,6 +1859,63 @@ NVC0LoweringPass::handleOUT(Instruction *i)
>>>> return true;
>>>> }
>>>>
>>>> +bool
>>>> +NVC0LoweringPass::handleCVT(Instruction *i)
>>>> +{
>>>> + if (isFloatType(i->dType) || isFloatType(i->sType) ||
>>>> + isSignedIntType(i->dType) xor isSignedIntType(i->sType))
>>
>> I know pre-C89 features are cool, but let's avoid using them. I know
>> characters like ^ were uncommon on the 1960's and 1970's teletypes,
>> but I think we're past those days now.
>
> Yeah… Will fix that.
So "xor" or "^" is bitwise not logical, since isSignedIntType() returns
a bool, which when cast to an int is guaranteed to be 0 or 1, this
should work fine.
And being a bitwise op its presedence means it will get evaluated
before the "||" operators in your condition which I believe is what
we want here, but can we please have a pair of parenthesis around the
"^" and its operands to make this more clear ?
Regards,
Hans
More information about the mesa-dev
mailing list