mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 21:50:12 +01:00
aco: change order in combine_minmax()
Prepare for future optimizations. 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/19933>
This commit is contained in:
parent
ce5838599d
commit
dfbc8e0192
2 changed files with 7 additions and 7 deletions
|
|
@ -2625,22 +2625,22 @@ bool
|
|||
combine_minmax(opt_ctx& ctx, aco_ptr<Instruction>& instr, aco_opcode opposite, aco_opcode minmax3)
|
||||
{
|
||||
/* TODO: this can handle SDWA min/max instructions by using opsel */
|
||||
if (combine_three_valu_op(ctx, instr, instr->opcode, minmax3, "012", 1 | 2))
|
||||
if (combine_three_valu_op(ctx, instr, instr->opcode, minmax3, "120", 1 | 2))
|
||||
return true;
|
||||
|
||||
/* min(-max(a, b), c) -> min3(c, -a, -b) *
|
||||
* max(-min(a, b), c) -> max3(c, -a, -b) */
|
||||
/* min(-max(a, b), c) -> min3(-a, -b, c) *
|
||||
* max(-min(a, b), c) -> max3(-a, -b, c) */
|
||||
for (unsigned swap = 0; swap < 2; swap++) {
|
||||
Operand operands[3];
|
||||
bool neg[3], abs[3], clamp, precise;
|
||||
uint8_t opsel = 0, omod = 0;
|
||||
bool inbetween_neg;
|
||||
if (match_op3_for_vop3(ctx, instr->opcode, opposite, instr.get(), swap, "012", operands, neg,
|
||||
if (match_op3_for_vop3(ctx, instr->opcode, opposite, instr.get(), swap, "120", operands, neg,
|
||||
abs, &opsel, &clamp, &omod, &inbetween_neg, NULL, NULL, &precise) &&
|
||||
inbetween_neg) {
|
||||
ctx.uses[instr->operands[swap].tempId()]--;
|
||||
neg[0] = !neg[0];
|
||||
neg[1] = !neg[1];
|
||||
neg[2] = !neg[2];
|
||||
create_vop3_for_op3(ctx, minmax3, instr, operands, neg, abs, opsel, clamp, omod);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -718,14 +718,14 @@ BEGIN_TEST(optimize.minmax)
|
|||
if (!setup_cs("v1", (amd_gfx_level)i))
|
||||
continue;
|
||||
|
||||
//! v1: %res0 = v_max3_f32 0, -0, %a
|
||||
//! v1: %res0 = v_max3_f32 -0, %a, 0
|
||||
//! p_unit_test 0, %res0
|
||||
Temp xor0 = fneg(inputs[0]);
|
||||
Temp min = bld.vop2(aco_opcode::v_min_f32, bld.def(v1), Operand::zero(), xor0);
|
||||
Temp xor1 = fneg(min);
|
||||
writeout(0, bld.vop2(aco_opcode::v_max_f32, bld.def(v1), Operand::zero(), xor1));
|
||||
|
||||
//! v1: %res1 = v_max3_f32 0, -0, -%a
|
||||
//! v1: %res1 = v_max3_f32 -0, -%a, 0
|
||||
//! p_unit_test 1, %res1
|
||||
min = bld.vop2(aco_opcode::v_min_f32, bld.def(v1), Operand::zero(), Operand(inputs[0]));
|
||||
xor1 = fneg(min);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue