[4, 4], [src_type, src_type], False, _2src_commutative,
final(reduce_(reduce_(src0, src1), reduce_(src2, src3))))
-binop("fadd", tfloat, _2src_commutative + associative, "src0 + src1")
+binop("fadd", tfloat, _2src_commutative + associative,"""
+if (nir_is_rounding_mode_rtz(execution_mode, bit_size)) {
+ if (bit_size == 64)
+ dst = _mesa_double_add_rtz(src0, src1);
+ else
+ dst = _mesa_double_to_float_rtz((double)src0 + (double)src1);
+} else {
+ dst = src0 + src1;
+}
+""")
binop("iadd", tint, _2src_commutative + associative, "src0 + src1")
binop("iadd_sat", tint, _2src_commutative, """
src1 > 0 ?
""")
binop("usub_sat", tuint, "", "src0 < src1 ? 0 : src0 - src1")
-binop("fsub", tfloat, "", "src0 - src1")
+binop("fsub", tfloat, "", """
+if (nir_is_rounding_mode_rtz(execution_mode, bit_size)) {
+ if (bit_size == 64)
+ dst = _mesa_double_sub_rtz(src0, src1);
+ else
+ dst = _mesa_double_to_float_rtz((double)src0 - (double)src1);
+} else {
+ dst = src0 - src1;
+}
+""")
binop("isub", tint, "", "src0 - src1")
-binop("fmul", tfloat, _2src_commutative + associative, "src0 * src1")
+binop("fmul", tfloat, _2src_commutative + associative, """
+if (nir_is_rounding_mode_rtz(execution_mode, bit_size)) {
+ if (bit_size == 64)
+ dst = _mesa_double_mul_rtz(src0, src1);
+ else
+ dst = _mesa_double_to_float_rtz((double)src0 * (double)src1);
+} else {
+ dst = src0 * src1;
+}
+""")
# low 32-bits of signed/unsigned integer multiply
binop("imul", tint, _2src_commutative + associative, "src0 * src1")
[src1_size, src2_size, src3_size],
[tuint, tuint, tuint], False, "", const_expr)
-triop("ffma", tfloat, _2src_commutative, "src0 * src1 + src2")
+triop("ffma", tfloat, _2src_commutative, """
+if (nir_is_rounding_mode_rtz(execution_mode, bit_size)) {
+ if (bit_size == 64)
+ dst = _mesa_double_fma_rtz(src0, src1, src2);
+ else if (bit_size == 32)
+ dst = _mesa_float_fma_rtz(src0, src1, src2);
+ else
+ dst = _mesa_double_to_float_rtz(_mesa_double_fma_rtz(src0, src1, src2));
+} else {
+ if (bit_size == 32)
+ dst = fmaf(src0, src1, src2);
+ else
+ dst = fma(src0, src1, src2);
+}
+""")
triop("flrp", tfloat, "", "src0 * (1 - src2) + src1 * src2")