aco: add tests for swap operand with opsel
authorGeorg Lehmann <dadschoorse@gmail.com>
Sun, 26 Mar 2023 19:00:55 +0000 (21:00 +0200)
committerMarge Bot <emma+marge@anholt.net>
Thu, 30 Mar 2023 03:34:35 +0000 (03:34 +0000)
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22069>

src/amd/compiler/tests/test_optimizer.cpp

index 4a943aa..da88439 100644 (file)
@@ -2006,3 +2006,25 @@ BEGIN_TEST(optimize.dpp_opsel)
 
    finish_opt_test();
 END_TEST
+
+BEGIN_TEST(optimize.apply_sgpr_swap_opsel)
+   //>> v1: %a, s1: %b = p_startpgm
+   if (!setup_cs("v1  s1", GFX11))
+      return;
+
+   Temp a = inputs[0];
+   Temp b = inputs[1];
+
+   Temp b_vgpr = bld.pseudo(aco_opcode::p_extract_vector, bld.def(v2b), bld.copy(bld.def(v1), b),
+                            Operand::c32(0));
+
+   Temp res0 = bld.tmp(v2b);
+   VALU_instruction& valu = bld.vop2(aco_opcode::v_sub_f16, Definition(res0), a, b_vgpr)->valu();
+   valu.opsel[0] = true;
+
+   //! v2b: %res0 = v_subrev_f16 %b, hi(%a)
+   //! p_unit_test 0, %res0
+   writeout(0, res0);
+
+   finish_opt_test();
+END_TEST