[Mesa-dev] [PATCH v3 3/4] nvc0/ir: Handle OP_BFIND when folding constant expressions
Tobias Klausmann
tobias.johannes.klausmann at mni.thm.de
Tue Jun 3 15:35:49 PDT 2014
Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
---
V3: Use BuildUtil for the Immediate instead of a type conversion
.../drivers/nouveau/codegen/nv50_ir_peephole.cpp | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 538e745..e4d91d7 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -944,6 +944,23 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
case OP_EX2:
unary(i, imm0);
break;
+ case OP_BFIND: {
+ int32_t res;
+ switch (i->dType) {
+ case TYPE_S32: res = util_last_bit_signed(imm0.reg.data.s32) - 1; break;
+ case TYPE_U32: res = util_last_bit(imm0.reg.data.u32) - 1; break;
+ default:
+ return;
+ }
+ if (i->subOp == NV50_IR_SUBOP_BFIND_SAMT && res >= 0)
+ res = 31 - res;
+ bld.setPosition(i, false); /* make sure bld is init'ed */
+ i->setSrc(0, bld.mkImm(res));
+ i->setSrc(1, NULL);
+ i->op = OP_MOV;
+ i->subOp = 0;
+ break;
+ }
default:
return;
}
--
1.8.4.5
More information about the mesa-dev
mailing list