{
uint8_t new_swizzle[4];
+ /* Searching only works on SSA values because, if it's not SSA, we can't
+ * know if the value changed between one instance of that value in the
+ * expression and another. Also, the replace operation will place reads of
+ * that value right before the last instruction in the expression we're
+ * replacing so those reads will happen after the original reads and may
+ * not be valid if they're register reads.
+ */
+ if (!instr->src[src].src.is_ssa)
+ return false;
+
/* If the source is an explicitly sized source, then we need to reset
* both the number of components and the swizzle.
*/
switch (value->type) {
case nir_search_value_expression:
- if (!instr->src[src].src.is_ssa)
- return false;
-
if (instr->src[src].src.ssa->parent_instr->type != nir_instr_type_alu)
return false;
assert(var->variable < NIR_SEARCH_MAX_VARIABLES);
if (state->variables_seen & (1 << var->variable)) {
- if (!nir_srcs_equal(state->variables[var->variable].src,
- instr->src[src].src))
+ if (state->variables[var->variable].src.ssa != instr->src[src].src.ssa)
return false;
assert(!instr->src[src].abs && !instr->src[src].negate);