diff --git a/src/intel/compiler/jay/jay_builder.h b/src/intel/compiler/jay/jay_builder.h index 2f4f768dd25..2ee5fc03e92 100644 --- a/src/intel/compiler/jay/jay_builder.h +++ b/src/intel/compiler/jay/jay_builder.h @@ -210,29 +210,32 @@ jay_collect(jay_builder *b, /* * Set the n'th channel of a def to index. This requires a copy-on-write. * - * This implementation could likely be optimized. + * This implementation could likely be optimized. Right now, we just decompress + * the def, update in-place, then collect back. */ static inline void -jay_insert_channel(jay_builder *b, jay_def *d, unsigned c, jay_def scalar) +jay_insert_channel_index(jay_builder *b, jay_def *d, unsigned c, uint32_t index) { uint32_t indices[JAY_MAX_DEF_LENGTH]; uint32_t count = jay_num_values(*d); - assert(scalar.file == d->file && !scalar.negate && !scalar.abs); assert(c < count && count <= ARRAY_SIZE(indices)); - /* First, decompress the def. */ jay_foreach_comp(*d, i) { indices[i] = jay_channel(*d, i); } - /* Next, update the indices in place */ - indices[c] = jay_index(scalar); - - /* Now collect it back. */ + indices[c] = index; jay_replace_src(d, jay_collect(b, d->file, indices, count)); } +static inline void +jay_insert_channel(jay_builder *b, jay_def *d, unsigned c, jay_def scalar) +{ + assert(scalar.file == d->file && !scalar.negate && !scalar.abs); + jay_insert_channel_index(b, d, c, jay_index(scalar)); +} + /* * Concatenate a list of vectors, collecting all the indices in order. */ diff --git a/src/intel/compiler/jay/jay_opt_propagate.c b/src/intel/compiler/jay/jay_opt_propagate.c index ed4818376f9..3e215f77b1f 100644 --- a/src/intel/compiler/jay/jay_opt_propagate.c +++ b/src/intel/compiler/jay/jay_opt_propagate.c @@ -147,6 +147,8 @@ propagate_forwards(jay_function *f) I->src[s].file == def->src[0].file) { jay_insert_channel(&b, &I->src[s], c, def->src[0]); + } else if (def->op == JAY_OPCODE_UNDEF && c > 0) { + jay_insert_channel_index(&b, &I->src[s], c, 0); } } @@ -189,6 +191,12 @@ propagate_forwards(jay_function *f) propagate_modifier(I, s, def); } else if (def->op == JAY_OPCODE_NOT && !jay_uses_implicit_flag(def)) { propagate_not(I, s, def); + } else if (def->op == JAY_OPCODE_UNDEF && + I->op == JAY_OPCODE_MOV && + !jay_uses_implicit_flag(I)) { + + I->op = JAY_OPCODE_UNDEF; + jay_shrink_sources(I, 0); } }