Mesa (master): nv50/ir: properly set the type of the constant folding result

Ilia Mirkin imirkin at kemper.freedesktop.org
Sat Nov 7 00:41:37 UTC 2015


Module: Mesa
Branch: master
Commit: 393d0c336bc766a123e139ae85383663f81e00d1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=393d0c336bc766a123e139ae85383663f81e00d1

Author: Ilia Mirkin <imirkin at alum.mit.edu>
Date:   Fri Nov  6 19:28:29 2015 -0500

nv50/ir: properly set the type of the constant folding result

This removes the hack used for merge, which only covers a fraction of
the cases.

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>

---

 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp |    8 ++++----
 1 file changed, 4 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 f095597..0f1dcf0 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -448,7 +448,7 @@ ConstantFolding::expr(Instruction *i,
 {
    struct Storage *const a = &imm0.reg, *const b = &imm1.reg;
    struct Storage res;
-   uint8_t fixSrc0Size = 0;
+   DataType type = i->dType;
 
    memset(&res.data, 0, sizeof(res.data));
 
@@ -590,6 +590,7 @@ ConstantFolding::expr(Instruction *i,
       // 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;
+      type = TYPE_U32;
       break;
    case OP_MERGE:
       switch (i->dType) {
@@ -597,7 +598,6 @@ ConstantFolding::expr(Instruction *i,
       case TYPE_S64:
       case TYPE_F64:
          res.data.u64 = (((uint64_t)b->data.u32) << 32) | a->data.u32;
-         fixSrc0Size = 8;
          break;
       default:
          return;
@@ -616,8 +616,8 @@ ConstantFolding::expr(Instruction *i,
    i->setSrc(1, NULL);
 
    i->getSrc(0)->reg.data = res.data;
-   if (fixSrc0Size)
-      i->getSrc(0)->reg.size = fixSrc0Size;
+   i->getSrc(0)->reg.type = type;
+   i->getSrc(0)->reg.size = typeSizeof(type);
 
    switch (i->op) {
    case OP_MAD:




More information about the mesa-commit mailing list