nir: Add support for 2src_commutative ops that have 3 sources
v2: Instead of handling 3 sources as a special case, generalize with loops to N sources. Suggested by Jason. v3: Further generalize by only checking that number of sources is >= 2. Suggested by Jason. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
@@ -408,7 +408,11 @@ match_expression(const nir_search_expression *expr, nir_alu_instr *instr,
|
||||
|
||||
bool matched = true;
|
||||
for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
|
||||
if (!match_value(expr->srcs[i], instr, i ^ comm_op_flip,
|
||||
/* 2src_commutative instructions that have 3 sources are only commutative
|
||||
* in the first two sources. Source 2 is always source 2.
|
||||
*/
|
||||
if (!match_value(expr->srcs[i], instr,
|
||||
i < 2 ? i ^ comm_op_flip : i,
|
||||
num_components, swizzle, state)) {
|
||||
matched = false;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user