nir: Delete bany, ball, fany, fall.
authorMatt Turner <mattst88@gmail.com>
Mon, 30 Nov 2015 22:35:08 +0000 (14:35 -0800)
committerMatt Turner <mattst88@gmail.com>
Fri, 18 Dec 2015 18:20:13 +0000 (13:20 -0500)
As in the previous patches, these can be implemented as

   any(v) -> any_nequal(v, false)
   all(v) -> all_equal(v, true)

and their removal simplifies the code in the next patch.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/gallium/auxiliary/nir/tgsi_to_nir.c
src/glsl/nir/nir_lower_alu_to_scalar.c
src/glsl/nir/nir_opcodes.py
src/mesa/drivers/dri/i965/brw_fs_nir.cpp
src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c
src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
src/mesa/program/prog_to_nir.c

index 5def6d3f32a454a210185f942382ee848415948a..80821572f564b1f6dd09a782107ab4d9ababc2ec 100644 (file)
@@ -1069,7 +1069,9 @@ ttn_kill(nir_builder *b, nir_op op, nir_alu_dest dest, nir_ssa_def **src)
 static void
 ttn_kill_if(nir_builder *b, nir_op op, nir_alu_dest dest, nir_ssa_def **src)
 {
-   nir_ssa_def *cmp = nir_bany4(b, nir_flt(b, src[0], nir_imm_float(b, 0.0)));
+   nir_ssa_def *cmp = nir_bany_inequal4(b, nir_flt(b, src[0],
+                                                   nir_imm_float(b, 0.0)),
+                                        nir_imm_int(b, 0));
    nir_intrinsic_instr *discard =
       nir_intrinsic_instr_create(b->shader, nir_intrinsic_discard_if);
    discard->src[0] = nir_src_for_ssa(cmp);
index 9313fc0f97ebcd9efa0223d0491eed3b165fc138..d267ca383ab2b68e940fcd480701a77acfc307c0 100644 (file)
@@ -137,10 +137,6 @@ lower_alu_instr_scalar(nir_alu_instr *instr, nir_builder *b)
       LOWER_REDUCTION(nir_op_bany_inequal, nir_op_ine, nir_op_ior);
       LOWER_REDUCTION(nir_op_fall_equal, nir_op_seq, nir_op_fand);
       LOWER_REDUCTION(nir_op_fany_nequal, nir_op_sne, nir_op_for);
-      LOWER_REDUCTION(nir_op_ball, nir_op_imov, nir_op_iand);
-      LOWER_REDUCTION(nir_op_bany, nir_op_imov, nir_op_ior);
-      LOWER_REDUCTION(nir_op_fall, nir_op_fmov, nir_op_fand);
-      LOWER_REDUCTION(nir_op_fany, nir_op_fmov, nir_op_for);
 
    default:
       break;
index 37d3dfc45886737cbba5b6bfa619b39fb8d85e47..1cd01a4fe92bd4d633272283973dd1658102a75b 100644 (file)
@@ -167,13 +167,6 @@ unop_convert("i2b", tint, tbool, "src0 != 0")
 unop_convert("b2i", tbool, tint, "src0 ? 1 : 0") # Boolean-to-int conversion
 unop_convert("u2f", tuint, tfloat, "src0") # Unsigned-to-float conversion.
 
-unop_reduce("bany", 1, tbool, tbool, "{src}", "{src0} || {src1}", "{src}")
-unop_reduce("ball", 1, tbool, tbool, "{src}", "{src0} && {src1}", "{src}")
-unop_reduce("fany", 1, tfloat, tfloat, "{src} != 0.0f", "{src0} || {src1}",
-            "{src} ? 1.0f : 0.0f")
-unop_reduce("fall", 1, tfloat, tfloat, "{src} != 0.0f", "{src0} && {src1}",
-            "{src} ? 1.0f : 0.0f")
-
 # Unary floating-point rounding operations.
 
 
index f08f910ba278139c64c28150dbb76b9a9b7f09d9..faa26704b2cc14b9823abd1b2bab4aeab9f7365c 100644 (file)
@@ -841,12 +841,6 @@ fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr)
    case nir_op_fdot2:
    case nir_op_fdot3:
    case nir_op_fdot4:
-   case nir_op_bany2:
-   case nir_op_bany3:
-   case nir_op_bany4:
-   case nir_op_ball2:
-   case nir_op_ball3:
-   case nir_op_ball4:
    case nir_op_ball_fequal2:
    case nir_op_ball_iequal2:
    case nir_op_ball_fequal3:
index c995d2b7e2da84d45982efb154d959b5c61483b7..f4d23d81260d931eb7608ee10d49051c164f87f1 100644 (file)
@@ -109,9 +109,6 @@ analyze_boolean_resolves_block(nir_block *block, void *void_state)
          uint8_t resolve_status;
          nir_alu_instr *alu = nir_instr_as_alu(instr);
          switch (alu->op) {
-         case nir_op_bany2:
-         case nir_op_bany3:
-         case nir_op_bany4:
          case nir_op_ball_fequal2:
          case nir_op_ball_iequal2:
          case nir_op_ball_fequal3:
index f965b39360f4a81ff027da614b8a1923f12ad76c..3664c4bafbadcb8d13a1e0d9ab00411eb97e216d 100644 (file)
@@ -1419,20 +1419,6 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
       inst->saturate = instr->dest.saturate;
       break;
 
-   case nir_op_bany2:
-   case nir_op_bany3:
-   case nir_op_bany4: {
-      unsigned swiz =
-         brw_swizzle_for_size(nir_op_infos[instr->op].input_sizes[0]);
-
-      emit(CMP(dst_null_d(), swizzle(op[0], swiz), brw_imm_d(0),
-               BRW_CONDITIONAL_NZ));
-      emit(MOV(dst, brw_imm_d(0)));
-      inst = emit(MOV(dst, brw_imm_d(~0)));
-      inst->predicate = BRW_PREDICATE_ALIGN16_ANY4H;
-      break;
-   }
-
    case nir_op_fabs:
    case nir_op_iabs:
    case nir_op_fneg:
index 539e3c0531238ebd725c940ff9d9b46380809ad3..ff671592763cb4012929ba3ead8f62bbba19049d 100644 (file)
@@ -554,8 +554,8 @@ static void
 ptn_kil(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src)
 {
    nir_ssa_def *cmp = b->shader->options->native_integers ?
-      nir_bany4(b, nir_flt(b, src[0], nir_imm_float(b, 0.0))) :
-      nir_fany4(b, nir_slt(b, src[0], nir_imm_float(b, 0.0)));
+      nir_bany_inequal4(b, nir_flt(b, src[0], nir_imm_float(b, 0.0)), nir_imm_int(b, 0)) :
+      nir_fany_nequal4(b, nir_slt(b, src[0], nir_imm_float(b, 0.0)), nir_imm_float(b, 0.0));
 
    nir_intrinsic_instr *discard =
       nir_intrinsic_instr_create(b->shader, nir_intrinsic_discard_if);