From d76c204d0564701b4b8b6a2bdda50e2939683e66 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 13 Nov 2017 11:17:41 -0800 Subject: util: Move util_is_power_of_two to bitscan.h and rename to util_is_power_of_two_or_zero MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new name make the zero-input behavior more obvious. The next patch adds a new function with different zero-input behavior. Signed-off-by: Ian Romanick Suggested-by: Matt Turner Reviewed-by: Alejandro PiƱeiro --- src/gallium/drivers/nouveau/codegen/nv50_ir.cpp | 2 +- src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gallium/drivers/nouveau/codegen') diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp index 6f12df70a11..c987da99085 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp @@ -423,7 +423,7 @@ ImmediateValue::isNegative() const bool ImmediateValue::isPow2() const { - return util_is_power_of_two(reg.data.u32); + return util_is_power_of_two_or_zero(reg.data.u32); } void diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp index 48cf74950df..39177bd044b 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp @@ -1305,7 +1305,7 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s) src->op == OP_SHR && src->src(1).getImmediate(imm1) && i->src(t).mod == Modifier(0) && - util_is_power_of_two(imm0.reg.data.u32 + 1)) { + util_is_power_of_two_or_zero(imm0.reg.data.u32 + 1)) { // low byte = offset, high byte = width uint32_t ext = (util_last_bit(imm0.reg.data.u32) << 8) | imm1.reg.data.u32; i->op = OP_EXTBF; @@ -1314,7 +1314,7 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s) } else if (src->op == OP_SHL && src->src(1).getImmediate(imm1) && i->src(t).mod == Modifier(0) && - util_is_power_of_two(~imm0.reg.data.u32 + 1) && + util_is_power_of_two_or_zero(~imm0.reg.data.u32 + 1) && util_last_bit(~imm0.reg.data.u32) <= imm1.reg.data.u32) { i->op = OP_MOV; i->setSrc(s, NULL); -- cgit v1.2.3