summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2019-04-17 10:12:48 -0700
committerEric Anholt <[email protected]>2019-04-19 08:45:14 -0700
commit38c75aff4cb07a68d8956e0f96f3167cfe3fa964 (patch)
tree67d6bba6a45246dbe7f45cdbc9e46f263eac1021 /src/compiler
parent9ac5ec2f90f8b6b2c0e67039b1ae7590374be872 (diff)
nir: Use the nir_builder _imm helpers in setting up deref offsets.
When looking at the dEQP nested_struct_array_dynamic_index_fragment code after lowering, I was horrified at the amount of adding and multiplying by 0 we were doing. The builder _imm helpers handle that for you so that the following optimization passes have less work to do. Plus, it's easier to read. Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_deref.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c
index 93412b1eb6d..f1e6eee7745 100644
--- a/src/compiler/nir/nir_deref.c
+++ b/src/compiler/nir/nir_deref.c
@@ -206,16 +206,15 @@ nir_build_deref_offset(nir_builder *b, nir_deref_instr *deref,
for (nir_deref_instr **p = &path.path[1]; *p; p++) {
if ((*p)->deref_type == nir_deref_type_array) {
nir_ssa_def *index = nir_ssa_for_src(b, (*p)->arr.index, 1);
- nir_ssa_def *stride =
- nir_imm_int(b, type_get_array_stride((*p)->type, size_align));
- offset = nir_iadd(b, offset, nir_imul(b, index, stride));
+ int stride = type_get_array_stride((*p)->type, size_align);
+ offset = nir_iadd(b, offset, nir_imul_imm(b, index, stride));
} else if ((*p)->deref_type == nir_deref_type_struct) {
/* p starts at path[1], so this is safe */
nir_deref_instr *parent = *(p - 1);
unsigned field_offset =
struct_type_get_field_offset(parent->type, size_align,
(*p)->strct.index);
- offset = nir_iadd(b, offset, nir_imm_int(b, field_offset));
+ offset = nir_iadd_imm(b, offset, field_offset);
} else {
unreachable("Unsupported deref type");
}