[Mesa-dev] [PATCH 4/4] nvc0/ir: Handle OP_BFIND when folding constant expressions

Tobias Klausmann tobias.johannes.klausmann at mni.thm.de
Thu May 29 12:43:56 PDT 2014


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

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 68b9a6d..a56756c 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -556,6 +556,20 @@ ConstantFolding::expr(Instruction *i,
       }
       break;
    }
+   case OP_BFIND: {
+      int shift = 0;
+      if (i->subOp == NV50_IR_SUBOP_BFIND_SAMT)
+         shift = 32 - (b->data.u32 & 0xff);
+      switch (i->dType) {
+      case TYPE_S32:
+         res.data.s32 = util_last_bit_signed(a->data.s32 >> shift)- 1; break;
+      case TYPE_U32:
+         res.data.u32 = util_last_bit(a->data.u32 >> shift) -1; break;
+      default:
+         return;
+      }
+      break;
+   }
    default:
       return;
    }
-- 
1.8.4.5



More information about the mesa-dev mailing list