etnaviv: Support negative float inline immediates
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Fri, 11 Nov 2022 18:05:24 +0000 (19:05 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 22 Nov 2022 18:39:12 +0000 (18:39 +0000)
Closes: #7652
Fixes: 45a111c21c2 ("nir/opt_algebraic: Fuse c - a * b to FMA")
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19776>

src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c

index 4f76384..e64eb8b 100644 (file)
@@ -498,8 +498,14 @@ emit_alu(struct etna_compile *c, nir_alu_instr * alu)
          src.neg = asrc->negate || (alu->op == nir_op_fneg);
          src.abs = asrc->abs || (alu->op == nir_op_fabs);
       } else {
-         assert(!asrc->negate && alu->op != nir_op_fneg);
+         assert(alu->op != nir_op_fneg);
          assert(!asrc->abs && alu->op != nir_op_fabs);
+
+         if (src.imm_type > 0)
+            assert(!asrc->negate);
+
+         if (asrc->negate && src.imm_type == 0)
+            src.imm_val ^= 0x80000;
       }
 
       srcs[i] = src;