Mesa (master): nir/idiv_const: Use the modern nir_src_as_* constant helpers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Sep 9 20:49:11 UTC 2020
Module: Mesa
Branch: master
Commit: c5dd54e600bef006cdebcb9d045a737d3d9785e7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c5dd54e600bef006cdebcb9d045a737d3d9785e7
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Tue Sep 8 18:37:05 2020 -0500
nir/idiv_const: Use the modern nir_src_as_* constant helpers
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6655>
---
src/compiler/nir/nir_opt_idiv_const.c | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/src/compiler/nir/nir_opt_idiv_const.c b/src/compiler/nir/nir_opt_idiv_const.c
index 0ddde99b2c0..3d940cee1c9 100644
--- a/src/compiler/nir/nir_opt_idiv_const.c
+++ b/src/compiler/nir/nir_opt_idiv_const.c
@@ -102,8 +102,7 @@ nir_opt_idiv_const_instr(nir_builder *b, nir_alu_instr *alu)
assert(alu->dest.dest.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 (!const_denom)
+ if (!nir_src_is_const(alu->src[1].src))
return false;
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]);
/* Get the denominator for the channel */
- int64_t d;
- switch (bit_size) {
- 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");
- }
+ int64_t d = nir_src_comp_as_int(alu->src[1].src,
+ alu->src[1].swizzle[comp]);
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) {
More information about the mesa-commit
mailing list