Mesa (master): nir/search: Use nir_src_is_const and friends
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Oct 22 19:24:47 UTC 2018
Module: Mesa
Branch: master
Commit: 7bae7828aabc93bc575d637794ee4b236af62bc8
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7bae7828aabc93bc575d637794ee4b236af62bc8
Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date: Sat Oct 20 12:17:30 2018 -0500
nir/search: Use nir_src_is_const and friends
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
---
src/compiler/nir/nir_search.c | 70 ++++++++-----------------------------------
1 file changed, 13 insertions(+), 57 deletions(-)
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
index 21fcbe7aae..9c5cb547a7 100644
--- a/src/compiler/nir/nir_search.c
+++ b/src/compiler/nir/nir_search.c
@@ -181,33 +181,14 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
case nir_search_value_constant: {
nir_search_constant *const_val = nir_search_value_as_constant(value);
- if (!instr->src[src].src.is_ssa)
+ if (!nir_src_is_const(instr->src[src].src))
return false;
- if (instr->src[src].src.ssa->parent_instr->type != nir_instr_type_load_const)
- return false;
-
- nir_load_const_instr *load =
- nir_instr_as_load_const(instr->src[src].src.ssa->parent_instr);
-
switch (const_val->type) {
case nir_type_float:
for (unsigned i = 0; i < num_components; ++i) {
- double val;
- switch (load->def.bit_size) {
- case 16:
- val = _mesa_half_to_float(load->value.u16[new_swizzle[i]]);
- break;
- case 32:
- val = load->value.f32[new_swizzle[i]];
- break;
- case 64:
- val = load->value.f64[new_swizzle[i]];
- break;
- default:
- unreachable("unknown bit size");
- }
-
+ double val = nir_src_comp_as_float(instr->src[src].src,
+ new_swizzle[i]);
if (val != const_val->data.d)
return false;
}
@@ -215,42 +196,17 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
case nir_type_int:
case nir_type_uint:
- case nir_type_bool32:
- switch (load->def.bit_size) {
- case 8:
- for (unsigned i = 0; i < num_components; ++i) {
- if (load->value.u8[new_swizzle[i]] !=
- (uint8_t)const_val->data.u)
- return false;
- }
- return true;
-
- case 16:
- for (unsigned i = 0; i < num_components; ++i) {
- if (load->value.u16[new_swizzle[i]] !=
- (uint16_t)const_val->data.u)
- return false;
- }
- return true;
-
- case 32:
- for (unsigned i = 0; i < num_components; ++i) {
- if (load->value.u32[new_swizzle[i]] !=
- (uint32_t)const_val->data.u)
- return false;
- }
- return true;
-
- case 64:
- for (unsigned i = 0; i < num_components; ++i) {
- if (load->value.u64[new_swizzle[i]] != const_val->data.u)
- return false;
- }
- return true;
-
- default:
- unreachable("unknown bit size");
+ case nir_type_bool32: {
+ unsigned bit_size = nir_src_bit_size(instr->src[src].src);
+ uint64_t mask = bit_size == 64 ? UINT64_MAX : (1ull << bit_size) - 1;
+ for (unsigned i = 0; i < num_components; ++i) {
+ uint64_t val = nir_src_comp_as_uint(instr->src[src].src,
+ new_swizzle[i]);
+ if ((val & mask) != (const_val->data.u & mask))
+ return false;
}
+ return true;
+ }
default:
unreachable("Invalid alu source type");
More information about the mesa-commit
mailing list