---
src/compiler/glsl/gl_nir_lower_samplers.c | 7 ++-
src/compiler/nir/nir_deref.c| 14 ++
src/compiler/nir/nir_gather_info.c | 6 ++
src/compiler/nir/nir_gs_count_vertices.c| 7 +++
src/compiler/nir/nir_lower_clip.c | 2 +-
src/compiler/nir/nir_lower_indirect_derefs.c| 4 ++--
src/compiler/nir/nir_lower_io.c | 6 ++
.../nir/nir_lower_io_arrays_to_elements.c | 11 +--
src/compiler/nir/nir_lower_locals_to_regs.c | 6 +++---
src/compiler/nir/nir_lower_two_sided_color.c| 2 +-
src/compiler/nir/nir_lower_vars_to_ssa.c| 14 +-
src/compiler/nir/nir_opt_dead_cf.c | 7 ++-
src/compiler/nir/nir_opt_find_array_copies.c| 13 +++--
src/compiler/nir/nir_opt_intrinsics.c | 4 ++--
src/compiler/nir/nir_opt_large_constants.c | 2 +-
src/compiler/nir/nir_split_vars.c | 17 -
src/compiler/nir/tests/vars_tests.cpp | 10 --
17 files changed, 56 insertions(+), 76 deletions(-)
diff --git a/src/compiler/glsl/gl_nir_lower_samplers.c
b/src/compiler/glsl/gl_nir_lower_samplers.c
index 593967b7108..1ee075cfd14 100644
--- a/src/compiler/glsl/gl_nir_lower_samplers.c
+++ b/src/compiler/glsl/gl_nir_lower_samplers.c
@@ -57,12 +57,9 @@ lower_tex_src_to_offset(nir_builder *b,
break;
case nir_deref_type_array: {
- nir_const_value *const_deref_index =
-nir_src_as_const_value(deref->arr.index);
-
- if (const_deref_index && index == NULL) {
+ if (nir_src_is_const(deref->arr.index) && index == NULL) {
/* We're still building a direct index */
-base_index += const_deref_index->u32[0] * array_elements;
+base_index += nir_src_as_uint(deref->arr.index) * array_elements;
} else {
if (index == NULL) {
/* We used to be direct but not anymore */
diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c
index 4a87ee84d8a..4a2e81956d1 100644
--- a/src/compiler/nir/nir_deref.c
+++ b/src/compiler/nir/nir_deref.c
@@ -112,7 +112,7 @@ nir_deref_instr_has_indirect(nir_deref_instr *instr)
return true;
if (instr->deref_type == nir_deref_type_array &&
- !nir_src_as_const_value(instr->arr.index))
+ !nir_src_is_const(instr->arr.index))
return true;
instr = nir_deref_instr_parent(instr);
@@ -160,7 +160,7 @@ nir_deref_instr_get_const_offset(nir_deref_instr *deref,
unsigned offset = 0;
for (nir_deref_instr **p = [1]; *p; p++) {
if ((*p)->deref_type == nir_deref_type_array) {
- offset += nir_src_as_const_value((*p)->arr.index)->u32[0] *
+ offset += nir_src_as_uint((*p)->arr.index) *
type_get_array_stride((*p)->type, size_align);
} else if ((*p)->deref_type == nir_deref_type_struct) {
/* p starts at path[1], so this is safe */
@@ -312,15 +312,13 @@ nir_compare_deref_paths(nir_deref_path *a_path,
b_tail->deref_type == nir_deref_type_array);
assert(a_tail->arr.index.is_ssa && b_tail->arr.index.is_ssa);
-nir_const_value *a_index_const =
- nir_src_as_const_value(a_tail->arr.index);
-nir_const_value *b_index_const =
- nir_src_as_const_value(b_tail->arr.index);
-if (a_index_const && b_index_const) {
+if (nir_src_is_const(a_tail->arr.index) &&
+nir_src_is_const(b_tail->arr.index)) {
/* If they're both direct and have different offsets, they
* don't even alias much less anything else.
*/
- if (a_index_const->u32[0] != b_index_const->u32[0])
+ if (nir_src_as_uint(a_tail->arr.index) !=
+ nir_src_as_uint(b_tail->arr.index))
return 0;
} else if (a_tail->arr.index.ssa == b_tail->arr.index.ssa) {
/* They're the same indirect, continue on */
diff --git a/src/compiler/nir/nir_gather_info.c
b/src/compiler/nir/nir_gather_info.c
index 30f0bc721d4..15d38f036b5 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -108,13 +108,11 @@ get_io_offset(nir_deref_instr *deref, bool
is_vertex_input)
for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d)) {
if (d->deref_type == nir_deref_type_array) {
- nir_const_value *const_index = nir_src_as_const_value(d->arr.index);
-
- if (!const_index)
+ if (!nir_src_is_const(d->arr.index))
return -1;
offset += glsl_count_attribute_slots(d->type, is_vertex_input) *
-const_index->u32[0];
+ nir_src_as_uint(d->arr.index);
}
/* TODO: we can get the offset for structs here see nir_lower_io() */
}
diff --git