broadcom/vc5: Stop lowering negates to subs.
authorEric Anholt <eric@anholt.net>
Thu, 26 Oct 2017 22:40:38 +0000 (15:40 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 30 Oct 2017 20:31:28 +0000 (13:31 -0700)
In the case of fneg(0.0), we were getting back 0.0 instead of -0.0.  We
were also needing an immediate 0 value for ineg, when there's an opcode to
do the job properly.

Fixes fs-floatBitsToInt-neg.shader_test.

src/broadcom/compiler/nir_to_vir.c

index 92ba6144bc5b2d9d39422ed6d7851f5b2f016003..43ee84d5bba795cc0e637099d8cc9c3ce9bef87a 100644 (file)
@@ -806,6 +806,14 @@ ntq_emit_alu(struct v3d_compile *c, nir_alu_instr *instr)
         case nir_op_imov:
                 result = vir_MOV(c, src[0]);
                 break;
+
+        case nir_op_fneg:
+                result = vir_XOR(c, src[0], vir_uniform_ui(c, 1 << 31));
+                break;
+        case nir_op_ineg:
+                result = vir_NEG(c, src[0]);
+                break;
+
         case nir_op_fmul:
                 result = vir_FMUL(c, src[0], src[1]);
                 break;
@@ -1984,7 +1992,6 @@ const nir_shader_compiler_options v3d_nir_options = {
         .lower_fpow = true,
         .lower_fsat = true,
         .lower_fsqrt = true,
-        .lower_negate = true,
         .native_integers = true,
 };