diff options
author | Tobias Klausmann <[email protected]> | 2014-06-04 00:35:49 +0200 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2014-06-06 00:00:26 -0400 |
commit | fdc1d96b0ff59e163ed9fe894a1e6d08d4204b94 (patch) | |
tree | 5512b3e51d67bf991a45eb764c66290a1257eb12 /src/gallium/drivers/nouveau | |
parent | 4674343e8f37f336b68bb04212c928f28af66958 (diff) |
nvc0/ir: Handle OP_BFIND when folding constant expressions
Signed-off-by: Tobias Klausmann <[email protected]>
Reviewed-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/gallium/drivers/nouveau')
-rw-r--r-- | src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp index 5254617d238..a91d698c5b2 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp @@ -940,6 +940,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; } |