aco: ignore precise flag when optimizing integer clamps

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16296>
This commit is contained in:
Rhys Perry 2022-04-29 17:23:20 +01:00 committed by Marge Bot
parent 61eb632775
commit 5d8f5615d0
2 changed files with 17 additions and 15 deletions

View File

@ -2851,7 +2851,8 @@ combine_clamp(opt_ctx& ctx, aco_ptr<Instruction>& instr, aco_opcode min, aco_opc
/* 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;

View File

@ -530,21 +530,22 @@ BEGIN_TEST(optimize.clamp)
bld.vop2(cfg.max, bld.def(v1), inputs[2], inputs[0])));
/* correct NaN behaviour with precise */
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);
//! 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));
//~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();
}