@@ -448,15 +448,15 @@ propagate_condition_eval(nir_builder *b, nir_if *nif, nir_src *use_src,
448448 if (!evaluate_if_condition (nif , b -> cursor , & bool_value ))
449449 return false;
450450
451- nir_ssa_def * def [2 ] = {0 };
451+ nir_ssa_def * def [4 ] = {0 };
452452 for (unsigned i = 0 ; i < nir_op_infos [alu -> op ].num_inputs ; i ++ ) {
453453 if (alu -> src [i ].src .ssa == use_src -> ssa ) {
454454 def [i ] = nir_imm_bool (b , bool_value );
455455 } else {
456456 def [i ] = alu -> src [i ].src .ssa ;
457457 }
458458 }
459- nir_ssa_def * nalu = nir_build_alu (b , alu -> op , def [0 ], def [1 ], NULL , NULL );
459+ nir_ssa_def * nalu = nir_build_alu (b , alu -> op , def [0 ], def [1 ], def [ 2 ], def [ 3 ] );
460460
461461 /* Rewrite use to use new alu instruction */
462462 nir_src new_src = nir_src_for_ssa (nalu );
@@ -472,14 +472,21 @@ propagate_condition_eval(nir_builder *b, nir_if *nif, nir_src *use_src,
472472static bool
473473can_propagate_through_alu (nir_src * src )
474474{
475- if (src -> parent_instr -> type == nir_instr_type_alu &&
476- (nir_instr_as_alu (src -> parent_instr )-> op == nir_op_ior ||
477- nir_instr_as_alu (src -> parent_instr )-> op == nir_op_iand ||
478- nir_instr_as_alu (src -> parent_instr )-> op == nir_op_inot ||
479- nir_instr_as_alu (src -> parent_instr )-> op == nir_op_b2i ))
480- return true;
475+ if (src -> parent_instr -> type != nir_instr_type_alu )
476+ return false;
481477
482- return false;
478+ nir_alu_instr * alu = nir_instr_as_alu (src -> parent_instr );
479+ switch (alu -> op ) {
480+ case nir_op_ior :
481+ case nir_op_iand :
482+ case nir_op_inot :
483+ case nir_op_b2i :
484+ return true;
485+ case nir_op_bcsel :
486+ return src == & alu -> src [0 ].src ;
487+ default :
488+ return false;
489+ }
483490}
484491
485492static bool
0 commit comments