[Nouveau] [PATCH v2] nv50/ir: constant fold OP_SPLIT

Tobias Klausmann tobias.johannes.klausmann at mni.thm.de
Fri Sep 30 21:50:15 UTC 2016


Split the source immediate value into two new values and create OP_MOV
instructions the two newly created values.

V2: get rid of special cases

Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 9875738..d56b057 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -932,6 +932,22 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
    Instruction *newi = i;
 
    switch (i->op) {
+   case OP_SPLIT: {
+      uint8_t size = typeSizeof(i->dType);
+      DataType type = typeOfSize(size / 2, isFloatType(i->dType),
+                                 isSignedType(i->dType));
+      if (likely(type != TYPE_NONE)) {
+         uint64_t val = imm0.reg.data.u64;
+         uint16_t shift = size * 8;
+         bld.setPosition(i, false);
+         for (int8_t d = 0; i->defExists(d); ++d) {
+            bld.mkMov(i->getDef(d), bld.mkImm(val & ((1 << shift) - 1)), type);
+            val >>= shift;
+         }
+         delete_Instruction(prog, i);
+      }
+   }
+   break;
    case OP_MUL:
       if (i->dType == TYPE_F32)
          tryCollapseChainedMULs(i, s, imm0);
-- 
2.10.0



More information about the Nouveau mailing list