nir: Avoid an extra NIR op in integer divide lowering.
authorEric Anholt <eric@anholt.net>
Mon, 7 Nov 2016 18:34:01 +0000 (10:34 -0800)
committerEric Anholt <eric@anholt.net>
Thu, 17 Nov 2016 03:45:01 +0000 (19:45 -0800)
NIR bools are ~0 for true, so ((unsigned)a >> 31) != 0 -> ((int)a >> 31).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/compiler/nir/nir_lower_idiv.c

index b1e7aeb03c8aa866c24f561916d63510f59617ab..6726b718aaa5a1cf7f4c670eaa2dc63f3e29d4f9 100644 (file)
@@ -101,8 +101,7 @@ convert_instr(nir_builder *bld, nir_alu_instr *alu)
    if (is_signed)  {
       /* fix the sign: */
       r = nir_ixor(bld, numer, denom);
-      r = nir_ushr(bld, r, nir_imm_int(bld, 31));
-      r = nir_i2b(bld, r);
+      r = nir_ishr(bld, r, nir_imm_int(bld, 31));
       b = nir_ineg(bld, q);
       q = nir_bcsel(bld, r, b, q);
    }