nir/vtn: Add type constant to image intrinsics
[mesa.git] / src / compiler / nir / nir_opt_if.c
index 9c32ab1cc57b16378cb1d2bdccfd8bf6e5a10d5a..8b35b167013c1f87f3e29049f3eb6d644b403412 100644 (file)
@@ -275,7 +275,7 @@ alu_instr_is_comparison(const nir_alu_instr *alu)
    case nir_op_flt32:
    case nir_op_fge32:
    case nir_op_feq32:
-   case nir_op_fne32:
+   case nir_op_fneu32:
    case nir_op_ilt32:
    case nir_op_ult32:
    case nir_op_ige32:
@@ -292,8 +292,7 @@ static bool
 alu_instr_is_type_conversion(const nir_alu_instr *alu)
 {
    return nir_op_infos[alu->op].num_inputs == 1 &&
-          nir_alu_type_get_base_type(nir_op_infos[alu->op].output_type) !=
-          nir_alu_type_get_base_type(nir_op_infos[alu->op].input_types[0]);
+          nir_op_infos[alu->op].output_type != nir_op_infos[alu->op].input_types[0];
 }
 
 /**
@@ -931,6 +930,17 @@ opt_if_simplification(nir_builder *b, nir_if *nif)
    nir_block *then_block = nir_if_last_then_block(nif);
    nir_block *else_block = nir_if_last_else_block(nif);
 
+   if (nir_block_ends_in_jump(else_block)) {
+      /* Even though this if statement has a jump on one side, we may still have
+       * phis afterwards.  Single-source phis can be produced by loop unrolling
+       * or dead control-flow passes and are perfectly legal.  Run a quick phi
+       * removal on the block after the if to clean up any such phis.
+       */
+      nir_block *const next_block =
+         nir_cf_node_as_block(nir_cf_node_next(&nif->cf_node));
+      nir_opt_remove_phis_block(next_block);
+   }
+
    rewrite_phi_predecessor_blocks(nif, then_block, else_block, else_block,
                                   then_block);