nir/idiv_const: Use the modern nir_src_as_* constant helpers

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6655>
This commit is contained in:
Jason Ekstrand
2020-09-08 18:37:05 -05:00
committed by Marge Bot
parent d86e38af2c
commit c5dd54e600

View File

@@ -102,8 +102,7 @@ nir_opt_idiv_const_instr(nir_builder *b, nir_alu_instr *alu)
assert(alu->dest.dest.is_ssa); assert(alu->dest.dest.is_ssa);
assert(alu->src[0].src.is_ssa && alu->src[1].src.is_ssa); assert(alu->src[0].src.is_ssa && alu->src[1].src.is_ssa);
nir_const_value *const_denom = nir_src_as_const_value(alu->src[1].src); if (!nir_src_is_const(alu->src[1].src))
if (!const_denom)
return false; return false;
unsigned bit_size = alu->src[1].src.ssa->bit_size; unsigned bit_size = alu->src[1].src.ssa->bit_size;
@@ -117,23 +116,8 @@ nir_opt_idiv_const_instr(nir_builder *b, nir_alu_instr *alu)
alu->src[0].swizzle[comp]); alu->src[0].swizzle[comp]);
/* Get the denominator for the channel */ /* Get the denominator for the channel */
int64_t d; int64_t d = nir_src_comp_as_int(alu->src[1].src,
switch (bit_size) { alu->src[1].swizzle[comp]);
case 8:
d = const_denom[alu->src[1].swizzle[comp]].i8;
break;
case 16:
d = const_denom[alu->src[1].swizzle[comp]].i16;
break;
case 32:
d = const_denom[alu->src[1].swizzle[comp]].i32;
break;
case 64:
d = const_denom[alu->src[1].swizzle[comp]].i64;
break;
default:
unreachable("Invalid bit size");
}
nir_alu_type d_type = nir_op_infos[alu->op].input_types[1]; nir_alu_type d_type = nir_op_infos[alu->op].input_types[1];
if (nir_alu_type_get_base_type(d_type) == nir_type_uint) { if (nir_alu_type_get_base_type(d_type) == nir_type_uint) {