diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2018-07-03 17:00:50 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2018-07-26 15:11:13 -0700 |
commit | 334689aa48aaed2910155f6d011df55f51495fd7 (patch) | |
tree | 78c24868613ed03b3b7c18361dee52d0a543bbb8 | |
parent | eab56383007a36acc3b60f154d402c9daf5b39c1 (diff) |
nir: Teach src_is_type about nir_instr_type_load_const
-rw-r--r-- | src/compiler/nir/nir_search.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c index 21fcbe7aaec..de9898b31f0 100644 --- a/src/compiler/nir/nir_search.c +++ b/src/compiler/nir/nir_search.c @@ -49,7 +49,8 @@ static const uint8_t identity_swizzle[NIR_MAX_VEC_COMPONENTS] = { 0, 1, 2, 3 }; * Used for satisfying 'a@type' constraints. */ static bool -src_is_type(nir_src src, nir_alu_type type) +src_is_type(nir_src src, nir_alu_type type, unsigned num_components, + const uint8_t *swizzle) { assert(type != nir_type_invalid); @@ -69,10 +70,14 @@ src_is_type(nir_src src, nir_alu_type type) case nir_op_iand: case nir_op_ior: case nir_op_ixor: - return src_is_type(src_alu->src[0].src, nir_type_bool) && - src_is_type(src_alu->src[1].src, nir_type_bool); + return src_is_type(src_alu->src[0].src, nir_type_bool, + num_components, swizzle) && + src_is_type(src_alu->src[1].src, nir_type_bool, + num_components, swizzle); case nir_op_inot: return src_is_type(src_alu->src[0].src, nir_type_bool); + return src_is_type(src_alu->src[0].src, nir_type_bool, + num_components, swizzle); default: break; } @@ -86,6 +91,20 @@ src_is_type(nir_src src, nir_alu_type type) return intr->intrinsic == nir_intrinsic_load_front_face || intr->intrinsic == nir_intrinsic_load_helper_invocation; } + } else if (src.ssa->parent_instr->type == nir_instr_type_load_const) { + if (type == nir_type_bool) { + const nir_const_value *const val = nir_src_as_const_value(src); + + assert(val != NULL); + + for (unsigned i = 0; i < num_components; i++) { + if (val->u32[swizzle[i]] != NIR_FALSE && + val->u32[swizzle[i]] != NIR_TRUE) + return false; + } + + return true; + } } /* don't know */ @@ -159,7 +178,8 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src, return false; if (var->type != nir_type_invalid && - !src_is_type(instr->src[src].src, var->type)) + !src_is_type(instr->src[src].src, var->type, num_components, + new_swizzle)) return false; state->variables_seen |= (1 << var->variable); |