Re: [Mesa-dev] [PATCH 5/5] nv50/ir: detect when a SLCT is equivalent to a SET

2016-10-21 Thread Ilia Mirkin
On Fri, Oct 21, 2016 at 2:39 AM, Karol Herbst  wrote:
>
>
> On 21 October 2016 8:30:33 a.m. GMT+02:00, Ilia Mirkin  
> wrote:
>>Signed-off-by: Ilia Mirkin 
>>---
>>.../drivers/nouveau/codegen/nv50_ir_peephole.cpp   | 23
>>++
>> 1 file changed, 19 insertions(+), 4 deletions(-)
>>
>>diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>>b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>>index f6fce44..c555430 100644
>>--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>>+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>>@@ -637,10 +637,25 @@ ConstantFolding::expr(Instruction *i,
>>   }
>>   break;
>>case OP_SLCT:
>>-  if (a->data.u32 != b->data.u32)
>>- return;
>>-  res.data.u32 = a->data.u32;
>>-  break;
>>+  if (a->data.u32 == b->data.u32) {
>>+ res.data.u32 = a->data.u32;
>>+ break;
>>+  }
>>+  if ((a->data.u32 == 0 && b->data.u32 == 0x) ||
>>+  (b->data.u32 == 0 && a->data.u32 == 0x)) {
>>+ bld.setPosition(i, false);
>
> why do you need the bld.setPosition here?

Because an earlier version of the code had a bld.loadImm(0). However I
cleverly got rid of that, and stupidly forgot the bld.setPosition.

>
>>+ CmpInstruction *ci = i->asCmp();
>>+ i->op = OP_SET;
>>+ i->dType = TYPE_U32;
>>+ if (a->data.u32 == 0) {
>>+ci->setCond = inverseCondCode(ci->setCond);
>>+i->setSrc(1, i->getSrc(0));
>>+ }
>>+ i->setSrc(0, i->getSrc(2));
>>+ i->moveSources(3, -1);
>>+ ++foldCount;
>>+  }
>>+  return;
>>case OP_EXTBF: {
>>   int offset = b->data.u32 & 0xff;
>>   int width = (b->data.u32 >> 8) & 0xff;
>>--
>>2.7.3
>>
>>___
>>mesa-dev mailing list
>>mesa-dev@lists.freedesktop.org
>>https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/5] nv50/ir: detect when a SLCT is equivalent to a SET

2016-10-21 Thread Karol Herbst


On 21 October 2016 8:30:33 a.m. GMT+02:00, Ilia Mirkin  
wrote:
>Signed-off-by: Ilia Mirkin 
>---
>.../drivers/nouveau/codegen/nv50_ir_peephole.cpp   | 23
>++
> 1 file changed, 19 insertions(+), 4 deletions(-)
>
>diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>index f6fce44..c555430 100644
>--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>@@ -637,10 +637,25 @@ ConstantFolding::expr(Instruction *i,
>   }
>   break;
>case OP_SLCT:
>-  if (a->data.u32 != b->data.u32)
>- return;
>-  res.data.u32 = a->data.u32;
>-  break;
>+  if (a->data.u32 == b->data.u32) {
>+ res.data.u32 = a->data.u32;
>+ break;
>+  }
>+  if ((a->data.u32 == 0 && b->data.u32 == 0x) ||
>+  (b->data.u32 == 0 && a->data.u32 == 0x)) {
>+ bld.setPosition(i, false);

why do you need the bld.setPosition here?

>+ CmpInstruction *ci = i->asCmp();
>+ i->op = OP_SET;
>+ i->dType = TYPE_U32;
>+ if (a->data.u32 == 0) {
>+ci->setCond = inverseCondCode(ci->setCond);
>+i->setSrc(1, i->getSrc(0));
>+ }
>+ i->setSrc(0, i->getSrc(2));
>+ i->moveSources(3, -1);
>+ ++foldCount;
>+  }
>+  return;
>case OP_EXTBF: {
>   int offset = b->data.u32 & 0xff;
>   int width = (b->data.u32 >> 8) & 0xff;
>-- 
>2.7.3
>
>___
>mesa-dev mailing list
>mesa-dev@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/mesa-dev

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 5/5] nv50/ir: detect when a SLCT is equivalent to a SET

2016-10-21 Thread Ilia Mirkin
Signed-off-by: Ilia Mirkin 
---
 .../drivers/nouveau/codegen/nv50_ir_peephole.cpp   | 23 ++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index f6fce44..c555430 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -637,10 +637,25 @@ ConstantFolding::expr(Instruction *i,
   }
   break;
case OP_SLCT:
-  if (a->data.u32 != b->data.u32)
- return;
-  res.data.u32 = a->data.u32;
-  break;
+  if (a->data.u32 == b->data.u32) {
+ res.data.u32 = a->data.u32;
+ break;
+  }
+  if ((a->data.u32 == 0 && b->data.u32 == 0x) ||
+  (b->data.u32 == 0 && a->data.u32 == 0x)) {
+ bld.setPosition(i, false);
+ CmpInstruction *ci = i->asCmp();
+ i->op = OP_SET;
+ i->dType = TYPE_U32;
+ if (a->data.u32 == 0) {
+ci->setCond = inverseCondCode(ci->setCond);
+i->setSrc(1, i->getSrc(0));
+ }
+ i->setSrc(0, i->getSrc(2));
+ i->moveSources(3, -1);
+ ++foldCount;
+  }
+  return;
case OP_EXTBF: {
   int offset = b->data.u32 & 0xff;
   int width = (b->data.u32 >> 8) & 0xff;
-- 
2.7.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev