Mesa (master): nir: Use the nir_builder _imm helpers in setting up deref offsets.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Apr 19 15:48:01 UTC 2019
Module: Mesa
Branch: master
Commit: 38c75aff4cb07a68d8956e0f96f3167cfe3fa964
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=38c75aff4cb07a68d8956e0f96f3167cfe3fa964
Author: Eric Anholt <eric at anholt.net>
Date: Wed Apr 17 10:12:48 2019 -0700
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 <jason at jlekstrand.net>
---
src/compiler/nir/nir_deref.c | 7 +++----
1 file 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");
}
More information about the mesa-commit
mailing list