/* max(min(src, upper), lower) returns upper if src is NaN, but
* med3(src, lower, upper) returns lower.
*/
- if (precise && instr->opcode != min)
+ if (precise && instr->opcode != min &&
+ (min == aco_opcode::v_min_f16 || min == aco_opcode::v_min_f32))
continue;
int const0_idx = -1, const1_idx = -1;
bld.vop2(cfg.max, bld.def(v1), inputs[2], inputs[0])));
/* correct NaN behaviour with precise */
-
- //! v1: %res7 = @med3 @ub, @lb, %a
- //! p_unit_test 7, %res7
- Builder::Result max = bld.vop2(cfg.max, bld.def(v1), cfg.lb, inputs[0]);
- max.def(0).setPrecise(true);
- Builder::Result min = bld.vop2(cfg.min, bld.def(v1), cfg.ub, max);
- max.def(0).setPrecise(true);
- writeout(7, min);
-
- //! v1: (precise)%res8_tmp = @min @ub, %a
- //! v1: %res8 = @max @lb, %res8_tmp
- //! p_unit_test 8, %res8
- min = bld.vop2(cfg.min, bld.def(v1), cfg.ub, inputs[0]);
- min.def(0).setPrecise(true);
- writeout(8, bld.vop2(cfg.max, bld.def(v1), cfg.lb, min));
+ if (cfg.min == aco_opcode::v_min_f16 || cfg.min == aco_opcode::v_min_f32) {
+ //~f(16|32)! v1: %res7 = @med3 @ub, @lb, %a
+ //~f(16|32)! p_unit_test 7, %res7
+ Builder::Result max = bld.vop2(cfg.max, bld.def(v1), cfg.lb, inputs[0]);
+ max.def(0).setPrecise(true);
+ Builder::Result min = bld.vop2(cfg.min, bld.def(v1), cfg.ub, max);
+ max.def(0).setPrecise(true);
+ writeout(7, min);
+
+ //~f(16|32)! v1: (precise)%res8_tmp = @min @ub, %a
+ //~f(16|32)! v1: %res8 = @max @lb, %res8_tmp
+ //~f(16|32)! p_unit_test 8, %res8
+ min = bld.vop2(cfg.min, bld.def(v1), cfg.ub, inputs[0]);
+ min.def(0).setPrecise(true);
+ writeout(8, bld.vop2(cfg.max, bld.def(v1), cfg.lb, min));
+ }
finish_opt_test();
}