Re: [Mesa-dev] [PATCH v2 3/6] nv50/ir: replace post_ra_dead by Instruction::isDead

2016-10-26 Thread Samuel Pitoiset

I'm definitely in favour of my first solution, ie.:

if (postRA)
  return post_ra_dead(this);

On 10/09/2016 11:04 AM, Karol Herbst wrote:

Signed-off-by: Karol Herbst 
---
 src/gallium/drivers/nouveau/codegen/nv50_ir.h|  2 +-
 .../drivers/nouveau/codegen/nv50_ir_peephole.cpp | 20 +++-
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h 
b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
index bedbdcc..9d1a72f 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
@@ -829,7 +829,7 @@ public:
}

inline bool isPseudo() const { return op < OP_MOV; }
-   bool isDead() const;
+   bool isDead(bool postRA = false) const;
bool isNop() const;
bool isCommutationLegal(const Instruction *) const; // must be adjacent !
bool isActionEqual(const Instruction *) const;
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 6efb29e..fd1fec6 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -61,7 +61,7 @@ Instruction::isNop() const
return false;
 }

-bool Instruction::isDead() const
+bool Instruction::isDead(bool postRA) const
 {
if (op == OP_STORE ||
op == OP_EXPORT ||
@@ -70,8 +70,11 @@ bool Instruction::isDead() const
op == OP_WRSV)
   return false;

+   if (postRA && op == OP_MOV && subOp == NV50_IR_SUBOP_MOV_FINAL)
+  return false;
+
for (int d = 0; defExists(d); ++d)
-  if (getDef(d)->refCount() || getDef(d)->reg.data.id >= 0)
+  if (getDef(d)->refCount() || (!postRA && getDef(d)->reg.data.id >= 0))
  return false;

if (terminator || asFlow())
@@ -2959,15 +2962,6 @@ private:
virtual bool visit(BasicBlock *);
 };

-static bool
-post_ra_dead(Instruction *i)
-{
-   for (int d = 0; i->defExists(d); ++d)
-  if (i->getDef(d)->refCount())
- return false;
-   return true;
-}
-
 bool
 NV50PostRaConstantFolding::visit(BasicBlock *bb)
 {
@@ -3014,13 +3008,13 @@ NV50PostRaConstantFolding::visit(BasicBlock *bb)
 /* There's no post-RA dead code elimination, so do it here
  * XXX: if we add more code-removing post-RA passes, we might
  *  want to create a post-RA dead-code elim pass */
-if (post_ra_dead(vtmp->getInsn())) {
+if (vtmp->getInsn()->isDead(true)) {
Value *src = vtmp->getInsn()->getSrc(0);
// Careful -- splits will have already been removed from the
// functions. Don't double-delete.
if (vtmp->getInsn()->bb)
   delete_Instruction(prog, vtmp->getInsn());
-   if (src->getInsn() && post_ra_dead(src->getInsn()))
+   if (src->getInsn() && src->getInsn()->isDead(true))
   delete_Instruction(prog, src->getInsn());
 }



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


[Mesa-dev] [PATCH v2 3/6] nv50/ir: replace post_ra_dead by Instruction::isDead

2016-10-09 Thread Karol Herbst
Signed-off-by: Karol Herbst 
---
 src/gallium/drivers/nouveau/codegen/nv50_ir.h|  2 +-
 .../drivers/nouveau/codegen/nv50_ir_peephole.cpp | 20 +++-
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h 
b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
index bedbdcc..9d1a72f 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
@@ -829,7 +829,7 @@ public:
}
 
inline bool isPseudo() const { return op < OP_MOV; }
-   bool isDead() const;
+   bool isDead(bool postRA = false) const;
bool isNop() const;
bool isCommutationLegal(const Instruction *) const; // must be adjacent !
bool isActionEqual(const Instruction *) const;
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 6efb29e..fd1fec6 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -61,7 +61,7 @@ Instruction::isNop() const
return false;
 }
 
-bool Instruction::isDead() const
+bool Instruction::isDead(bool postRA) const
 {
if (op == OP_STORE ||
op == OP_EXPORT ||
@@ -70,8 +70,11 @@ bool Instruction::isDead() const
op == OP_WRSV)
   return false;
 
+   if (postRA && op == OP_MOV && subOp == NV50_IR_SUBOP_MOV_FINAL)
+  return false;
+
for (int d = 0; defExists(d); ++d)
-  if (getDef(d)->refCount() || getDef(d)->reg.data.id >= 0)
+  if (getDef(d)->refCount() || (!postRA && getDef(d)->reg.data.id >= 0))
  return false;
 
if (terminator || asFlow())
@@ -2959,15 +2962,6 @@ private:
virtual bool visit(BasicBlock *);
 };
 
-static bool
-post_ra_dead(Instruction *i)
-{
-   for (int d = 0; i->defExists(d); ++d)
-  if (i->getDef(d)->refCount())
- return false;
-   return true;
-}
-
 bool
 NV50PostRaConstantFolding::visit(BasicBlock *bb)
 {
@@ -3014,13 +3008,13 @@ NV50PostRaConstantFolding::visit(BasicBlock *bb)
 /* There's no post-RA dead code elimination, so do it here
  * XXX: if we add more code-removing post-RA passes, we might
  *  want to create a post-RA dead-code elim pass */
-if (post_ra_dead(vtmp->getInsn())) {
+if (vtmp->getInsn()->isDead(true)) {
Value *src = vtmp->getInsn()->getSrc(0);
// Careful -- splits will have already been removed from the
// functions. Don't double-delete.
if (vtmp->getInsn()->bb)
   delete_Instruction(prog, vtmp->getInsn());
-   if (src->getInsn() && post_ra_dead(src->getInsn()))
+   if (src->getInsn() && src->getInsn()->isDead(true))
   delete_Instruction(prog, src->getInsn());
 }
 
-- 
2.10.0

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