nir: Add fdph and fdph_replicated opcodes
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 22 Sep 2015 23:54:27 +0000 (16:54 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 23 Sep 2015 03:37:35 +0000 (20:37 -0700)
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/nir/nir_lower_vec_to_movs.c
src/glsl/nir/nir_opcodes.py
src/glsl/nir/nir_opt_algebraic.py

index b7ee4e8d33cd5f907dca02de64f66ee1eee9de17..622e59c688e88b020a57073e6c410a98df604a16 100644 (file)
@@ -89,7 +89,8 @@ has_replicated_dest(nir_alu_instr *alu)
 {
    return alu->op == nir_op_fdot_replicated2 ||
           alu->op == nir_op_fdot_replicated3 ||
-          alu->op == nir_op_fdot_replicated4;
+          alu->op == nir_op_fdot_replicated4 ||
+          alu->op == nir_op_fdph_replicated;
 }
 
 /* Attempts to coalesce the "move" from the given source of the vec to the
index 495d109375b995089ec05452f00defd5284febe3..f2d584fe484358fc53801dcc5a31b1a02b0e28c6 100644 (file)
@@ -456,6 +456,11 @@ binop_reduce("fdot", 1, tfloat, tfloat, "{src0} * {src1}", "{src0} + {src1}",
 binop_reduce("fdot_replicated", 4, tfloat, tfloat,
              "{src0} * {src1}", "{src0} + {src1}", "{src}")
 
+opcode("fdph", 1, tfloat, [3, 4], [tfloat, tfloat], "",
+       "src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w")
+opcode("fdph_replicated", 4, tfloat, [3, 4], [tfloat, tfloat], "",
+       "src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w")
+
 binop("fmin", tfloat, "", "fminf(src0, src1)")
 binop("imin", tint, commutative + associative, "src1 > src0 ? src0 : src1")
 binop("umin", tunsigned, commutative + associative, "src1 > src0 ? src0 : src1")
index 43558a547b4fbc8670ef4bf4b1db4bee91c913d5..585e5e0ae98cd585861000154a91c64c80a40716 100644 (file)
@@ -244,6 +244,7 @@ late_optimizations = [
    (('fdot2', a, b), ('fdot_replicated2', a, b), 'options->fdot_replicates'),
    (('fdot3', a, b), ('fdot_replicated3', a, b), 'options->fdot_replicates'),
    (('fdot4', a, b), ('fdot_replicated4', a, b), 'options->fdot_replicates'),
+   (('fdph', a, b), ('fdph_replicated', a, b), 'options->fdot_replicates'),
 ]
 
 print nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render()