-static bool
-alu_instr_is_bool(nir_alu_instr *instr)
-{
- switch (instr->op) {
- case nir_op_iand:
- case nir_op_ior:
- case nir_op_ixor:
- return src_is_bool(instr->src[0].src) && src_is_bool(instr->src[1].src);
- case nir_op_inot:
- return src_is_bool(instr->src[0].src);
- default:
- return (nir_alu_type_get_base_type(nir_op_infos[instr->op].output_type)
- == nir_type_bool);
+ /* Turn nir_type_bool32 into nir_type_bool...they're the same thing. */
+ if (nir_alu_type_get_base_type(type) == nir_type_bool)
+ type = nir_type_bool;
+
+ if (src.ssa->parent_instr->type == nir_instr_type_alu) {
+ nir_alu_instr *src_alu = nir_instr_as_alu(src.ssa->parent_instr);
+ nir_alu_type output_type = nir_op_infos[src_alu->op].output_type;
+
+ if (type == nir_type_bool) {
+ switch (src_alu->op) {
+ case nir_op_iand:
+ case nir_op_ior:
+ case nir_op_ixor:
+ return src_is_type(src_alu->src[0].src, nir_type_bool) &&
+ src_is_type(src_alu->src[1].src, nir_type_bool);
+ case nir_op_inot:
+ return src_is_type(src_alu->src[0].src, nir_type_bool);
+ default:
+ break;
+ }
+ }
+
+ return nir_alu_type_get_base_type(output_type) == type;