[Mesa-stable] [Mesa-dev] [PATCH] nv50/ir: skip optimizing ADD+SHL to SHLADD when src(1) is 0

Samuel Pitoiset samuel.pitoiset at gmail.com
Mon May 1 16:09:09 UTC 2017



On 05/01/2017 05:59 PM, Ilia Mirkin wrote:
> I think this is off. It shouldn't matter what the code sequence is,
> it's all representable. You need to teach replaceZero to not mess
> things up for SHLADD's src(1).

It's representable but stupid to do it. We should keep the ADD there and 
this also avoids a workaround in the replaceZero logic just for that.

IMHO, this is the better solution.

> 
> On Sat, Apr 29, 2017 at 12:01 PM, Samuel Pitoiset
> <samuel.pitoiset at gmail.com> wrote:
>> Doing '(a << b) + c' when b is 0 is dumb, ADD should be used
>> instead.
>>
>> This fixes a compilation error with Alien Isolation because
>> src(1) is expected to be an immediate value, and the
>> replaceZero logic will transform 0 to $r63 (or $r255).
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> Cc: "13.0 17.0 17.1" <mesa-stable at lists.freedesktop.org>
>> ---
>>   src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> index 4c92a1efb5..015def0391 100644
>> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> @@ -2224,6 +2224,9 @@ LateAlgebraicOpt::tryADDToSHLADD(Instruction *add)
>>      if (!shl->src(1).getImmediate(imm))
>>         return false;
>>
>> +   if (imm.isInteger(0))
>> +      return false;
>> +
>>      add->op = OP_SHLADD;
>>      add->setSrc(2, add->src(!s));
>>      // SHL can't have any modifiers, but the ADD source may have had
>> --
>> 2.12.2
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-stable mailing list