glsl: Use find_msb_uint to implement ir_unop_find_lsb
(X & -X) calculates a value with only the least significant bit of X set. Since there is only one bit set, the LSB is the MSB. v2: Remove extra int() cast. Suggested by Matt. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
@@ -1560,16 +1560,15 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
|
|||||||
|
|
||||||
case ir_unop_find_lsb:
|
case ir_unop_find_lsb:
|
||||||
for (unsigned c = 0; c < components; c++) {
|
for (unsigned c = 0; c < components; c++) {
|
||||||
if (op[0]->value.i[c] == 0)
|
switch (op[0]->type->base_type) {
|
||||||
data.i[c] = -1;
|
case GLSL_TYPE_UINT:
|
||||||
else {
|
data.i[c] = find_msb_uint(op[0]->value.u[c] & -op[0]->value.u[c]);
|
||||||
unsigned pos = 0;
|
break;
|
||||||
unsigned v = op[0]->value.u[c];
|
case GLSL_TYPE_INT:
|
||||||
|
data.i[c] = find_msb_uint(op[0]->value.i[c] & -op[0]->value.i[c]);
|
||||||
for (; !(v & 1); v >>= 1) {
|
break;
|
||||||
pos++;
|
default:
|
||||||
}
|
assert(0);
|
||||||
data.u[c] = pos;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user