All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nv50/ir: avoid messing up arg1 of PFETCH
@ 2015-05-23  6:06 Ilia Mirkin
       [not found] ` <1432361210-14711-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Ilia Mirkin @ 2015-05-23  6:06 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	mesa-dev-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: 10.5 10.6

There can be scenarios where the "indirect" arg of a PFETCH becomes
known, and so the code will attempt to propagate it. Use this
opportunity to just fold it into the first argument, and prevent the
load propagation pass from touching PFETCH further.

This fixes gs-input-array-vec4-index-rd.shader_test and
vs-output-array-vec4-index-wr-before-gs.shader_test on nvc0 at least.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.5 10.6" <mesa-stable@lists.freedesktop.org>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 72dd31e..98e3d1f 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -236,6 +236,9 @@ LoadPropagation::visit(BasicBlock *bb)
       if (i->op == OP_CALL) // calls have args as sources, they must be in regs
          continue;
 
+      if (i->op == OP_PFETCH) // pfetch expects arg1 to be a reg
+         continue;
+
       if (i->srcExists(1))
          checkSwapSrc01(i);
 
@@ -581,6 +584,11 @@ ConstantFolding::expr(Instruction *i,
    case OP_POPCNT:
       res.data.u32 = util_bitcount(a->data.u32 & b->data.u32);
       break;
+   case OP_PFETCH:
+      // The two arguments to pfetch are logically added together. Normally
+      // the second argument will not be constant, but that can happen.
+      res.data.u32 = a->data.u32 + b->data.u32;
+      break;
    default:
       return;
    }
@@ -610,6 +618,8 @@ ConstantFolding::expr(Instruction *i,
          bld.setPosition(i, false);
          i->setSrc(1, bld.loadImm(NULL, res.data.u32));
       }
+   } else if (i->op == OP_PFETCH) {
+      // Leave PFETCH alone... we just folded its 2 args into 1.
    } else {
       i->op = i->saturate ? OP_SAT : OP_MOV; /* SAT handled by unary() */
    }
-- 
2.3.6

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Mesa-dev] [PATCH] nv50/ir: avoid messing up arg1 of PFETCH
       [not found] ` <1432361210-14711-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
@ 2015-05-23 12:27   ` Tobias Klausmann
  0 siblings, 0 replies; 2+ messages in thread
From: Tobias Klausmann @ 2015-05-23 12:27 UTC (permalink / raw)
  To: Ilia Mirkin, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW



On 23.05.2015 08:06, Ilia Mirkin wrote:
> There can be scenarios where the "indirect" arg of a PFETCH becomes
> known, and so the code will attempt to propagate it. Use this
> opportunity to just fold it into the first argument, and prevent the
> load propagation pass from touching PFETCH further.
>
> This fixes gs-input-array-vec4-index-rd.shader_test and
> vs-output-array-vec4-index-wr-before-gs.shader_test on nvc0 at least.
>
> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
> Cc: "10.5 10.6" <mesa-stable@lists.freedesktop.org>
> ---
>   src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> index 72dd31e..98e3d1f 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> @@ -236,6 +236,9 @@ LoadPropagation::visit(BasicBlock *bb)
>         if (i->op == OP_CALL) // calls have args as sources, they must be in regs
>            continue;
>   
> +      if (i->op == OP_PFETCH) // pfetch expects arg1 to be a reg
> +         continue;
> +
>         if (i->srcExists(1))
>            checkSwapSrc01(i);
>   
> @@ -581,6 +584,11 @@ ConstantFolding::expr(Instruction *i,
>      case OP_POPCNT:
>         res.data.u32 = util_bitcount(a->data.u32 & b->data.u32);
>         break;
> +   case OP_PFETCH:
> +      // The two arguments to pfetch are logically added together. Normally
> +      // the second argument will not be constant, but that can happen.
> +      res.data.u32 = a->data.u32 + b->data.u32;
> +      break;
>      default:
>         return;
>      }
> @@ -610,6 +618,8 @@ ConstantFolding::expr(Instruction *i,
>            bld.setPosition(i, false);
>            i->setSrc(1, bld.loadImm(NULL, res.data.u32));
>         }
> +   } else if (i->op == OP_PFETCH) {
> +      // Leave PFETCH alone... we just folded its 2 args into 1.
>      } else {
>         i->op = i->saturate ? OP_SAT : OP_MOV; /* SAT handled by unary() */
>      }
this last part sure works, but it gets ugly, while you are at it, can 
you change it to a switch statement?
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-23 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-23  6:06 [PATCH] nv50/ir: avoid messing up arg1 of PFETCH Ilia Mirkin
     [not found] ` <1432361210-14711-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
2015-05-23 12:27   ` [Mesa-dev] " Tobias Klausmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.