Skip to contentSkip to conversation

nv50/ir: optimmize shl(a, 0) to a

PATCH In review Karol Herbst 3 participants 4 messages Apr 29, 2017 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nv50/ir: optimmize shl(a, 0) to a

helps two alien isolation shaders

shader-db:
total instructions in shared programs : 4251497 -> 4251494 (-0.00%)

total gprs used in shared programs    : 513962 -> 513962 (0.00%)
total local used in shared programs   : 29797 -> 29797 (0.00%)
total bytes used in shared programs   : 38960264 -> 38960232 (-0.00%)

local gpr inst bytes
helped 0 0 2 2
hurt 0 0 0 0

---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 5 +++++
 1 file changed, 5 insertions(+)
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +5 -0
index 015def0391..a2446e4df8 100644
@@ -1284,6 +1284,11 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
 
    case OP_SHL:
    {
+      if (s == 1 && imm0.isInteger(0)) {
+         i->op = OP_MOV;
+         i->setSrc(1, NULL);
+         break;
+      }
       if (s != 1 || i->src(0).mod != Modifier(0))
          break;
       // try to concatenate shifts
Signature · 6 lines
2.12.2

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

A message that is not in the archive (sent off-list or not yet received): 20170429164604.3263-1-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

Reviewed-by
#2 lore raw

"optimmize" ? No need to resend just for that though.

Quoted 24 lines · Karol Herbst

helps two alien isolation shaders

shader-db:
total instructions in shared programs : 4251497 -> 4251494 (-0.00%)

total gprs used in shared programs    : 513962 -> 513962 (0.00%)
total local used in shared programs   : 29797 -> 29797 (0.00%)
total bytes used in shared programs   : 38960264 -> 38960232 (-0.00%)

local gpr inst bytes
helped 0 0 2 2
hurt 0 0 0 0

---
  src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 5 +++++
  1 file changed, 5 insertions(+)
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +0 -0
index 015def0391..a2446e4df8 100644
@@ -1284,6 +1284,11 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
 

src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s) · line 1294

Quoted 10 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +5 -0
     case OP_SHL:
     {
+      if (s == 1 && imm0.isInteger(0)) {
+         i->op = OP_MOV;
+         i->setSrc(1, NULL);
+         break;
+      }
        if (s != 1 || i->src(0).mod != Modifier(0))
           break;
        // try to concatenate shifts

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

Reviewed-by
#3 lore raw
In reply to a message not in the archive
Quoted 22 lines · Karol Herbst

helps two alien isolation shaders

shader-db:
total instructions in shared programs : 4251497 -> 4251494 (-0.00%)

total gprs used in shared programs    : 513962 -> 513962 (0.00%)
total local used in shared programs   : 29797 -> 29797 (0.00%)
total bytes used in shared programs   : 38960264 -> 38960232 (-0.00%)

local gpr inst bytes
helped 0 0 2 2
hurt 0 0 0 0

---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 5 +++++
 1 file changed, 5 insertions(+)
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +0 -0
index 015def0391..a2446e4df8 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s) · line 1293

Quoted 10 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +5 -0
@@ -1284,6 +1284,11 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
 
    case OP_SHL:
    {
+      if (s == 1 && imm0.isInteger(0)) {
+         i->op = OP_MOV;
+         i->setSrc(1, NULL);
+         break;
+      }
       if (s != 1 || i->src(0).mod != Modifier(0))
          break;

Interesting. This suggests that src(0) may have modifiers, although I can't imagine what that'd be. Perhaps it can take a neg? In that case, you need to fix the OP_MOV above -- should probably do it anyways, i.e. i->op = i->src(0).mod.getOp() or something. With that, this is

Separately, I just noticed that we don't appear to have any 0 << x or 0 >> y or EXTBF or anything like that. I doubt it comes up too often though.

Quoted 4 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +0 -1
       // try to concatenate shifts
--

2.12.2

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#4 lore raw

2017-04-29 21:03 GMT+02:00 Ilia Mirkin <[email protected]>:

Quoted 24 lines · Karol Herbst
Quoted 23 lines

helps two alien isolation shaders

shader-db:
total instructions in shared programs : 4251497 -> 4251494 (-0.00%)

total gprs used in shared programs    : 513962 -> 513962 (0.00%)
total local used in shared programs   : 29797 -> 29797 (0.00%)
total bytes used in shared programs   : 38960264 -> 38960232 (-0.00%)

local gpr inst bytes
helped 0 0 2 2
hurt 0 0 0 0

---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 5 +++++
 1 file changed, 5 insertions(+)
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +0 -0
index 015def0391..a2446e4df8 100644
@@ -1284,6 +1284,11 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
 
Quoted 15 lines

src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s) · line 1293

Quoted 9 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +5 -0
    case OP_SHL:
    {
+      if (s == 1 && imm0.isInteger(0)) {
+         i->op = OP_MOV;
+         i->setSrc(1, NULL);
+         break;
+      }
       if (s != 1 || i->src(0).mod != Modifier(0))
          break;

Interesting. This suggests that src(0) may have modifiers, although I can't imagine what that'd be. Perhaps it can take a neg? In that case, you need to fix the OP_MOV above -- should probably do it anyways, i.e. i->op = i->src(0).mod.getOp() or something. With that, this is

I looked through the emitter and there seem to be no flags. Envydis and nvdisasm seem to think the same.
Will fix it up nethertheless.

Quoted 10 lines

Separately, I just noticed that we don't appear to have any 0 << x or 0 >> y or EXTBF or anything like that. I doubt it comes up too often though.

Quoted 4 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +0 -1
       // try to concatenate shifts
--

2.12.2

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev