17ec681f3Smrg/* 27ec681f3Smrg * Copyright © 2020 Valve Corporation 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 217ec681f3Smrg * IN THE SOFTWARE. 227ec681f3Smrg * 237ec681f3Smrg */ 247ec681f3Smrg#include "helpers.h" 257ec681f3Smrg#include <stdarg.h> 267ec681f3Smrg 277ec681f3Smrgusing namespace aco; 287ec681f3Smrg 297ec681f3SmrgBEGIN_TEST(validate.sdwa.allow) 307ec681f3Smrg for (unsigned i = GFX8; i <= GFX10; i++) { 317ec681f3Smrg //>> v1: %a, v1: %b, s1: %c, s1: %d = p_startpgm 327ec681f3Smrg if (!setup_cs("v1 v1 s1 s1", (chip_class)i)) 337ec681f3Smrg continue; 347ec681f3Smrg //>> Validation results: 357ec681f3Smrg //! Validation passed 367ec681f3Smrg 377ec681f3Smrg SDWA_instruction *sdwa = &bld.vop2_sdwa(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]).instr->sdwa(); 387ec681f3Smrg sdwa->neg[0] = sdwa->neg[1] = sdwa->abs[0] = sdwa->abs[1] = true; 397ec681f3Smrg 407ec681f3Smrg sdwa = &bld.vop2_sdwa(aco_opcode::v_mul_f32, bld.def(v1b), inputs[0], inputs[1]).instr->sdwa(); 417ec681f3Smrg 427ec681f3Smrg sdwa = &bld.vop2_sdwa(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]).instr->sdwa(); 437ec681f3Smrg sdwa->sel[0] = SubdwordSel::sbyte2; 447ec681f3Smrg sdwa->sel[1] = SubdwordSel::uword1; 457ec681f3Smrg 467ec681f3Smrg finish_validator_test(); 477ec681f3Smrg } 487ec681f3SmrgEND_TEST 497ec681f3Smrg 507ec681f3SmrgBEGIN_TEST(validate.sdwa.support) 517ec681f3Smrg for (unsigned i = GFX7; i <= GFX10; i++) { 527ec681f3Smrg //>> v1: %a, v1: %b, s1: %c, s1: %d = p_startpgm 537ec681f3Smrg if (!setup_cs("v1 v1 s1 s1", (chip_class)i)) 547ec681f3Smrg continue; 557ec681f3Smrg //>> Validation results: 567ec681f3Smrg 577ec681f3Smrg //~gfx7! SDWA is GFX8+ only: v1: %t0 = v_mul_f32 %a, %b dst_sel:dword src0_sel:dword src1_sel:dword 587ec681f3Smrg //~gfx7! Validation failed 597ec681f3Smrg //~gfx([89]|10)! Validation passed 607ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 617ec681f3Smrg 627ec681f3Smrg finish_validator_test(); 637ec681f3Smrg } 647ec681f3SmrgEND_TEST 657ec681f3Smrg 667ec681f3SmrgBEGIN_TEST(validate.sdwa.operands) 677ec681f3Smrg for (unsigned i = GFX8; i <= GFX10; i++) { 687ec681f3Smrg //>> v1: %vgpr0, v1: %vgp1, s1: %sgpr0, s1: %sgpr1 = p_startpgm 697ec681f3Smrg if (!setup_cs("v1 v1 s1 s1", (chip_class)i)) 707ec681f3Smrg continue; 717ec681f3Smrg //>> Validation results: 727ec681f3Smrg 737ec681f3Smrg //~gfx8! Wrong source position for SGPR argument: v1: %_ = v_mul_f32 %sgpr0, %vgpr1 dst_sel:dword src0_sel:dword src1_sel:dword 747ec681f3Smrg //~gfx8! Wrong source position for SGPR argument: v1: %_ = v_mul_f32 %vgpr0, %sgpr1 dst_sel:dword src0_sel:dword src1_sel:dword 757ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_mul_f32, bld.def(v1), inputs[2], inputs[1]); 767ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[3]); 777ec681f3Smrg 787ec681f3Smrg //~gfx8! Wrong source position for constant argument: v1: %_ = v_mul_f32 4, %vgpr1 dst_sel:dword src0_sel:dword src1_sel:dword 797ec681f3Smrg //~gfx8! Wrong source position for constant argument: v1: %_ = v_mul_f32 %vgpr0, 4 dst_sel:dword src0_sel:dword src1_sel:dword 807ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_mul_f32, bld.def(v1), Operand::c32(4u), inputs[1]); 817ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], Operand::c32(4u)); 827ec681f3Smrg 837ec681f3Smrg //! Literal applied on wrong instruction format: v1: %_ = v_mul_f32 0x1234, %vgpr1 dst_sel:dword src0_sel:dword src1_sel:dword 847ec681f3Smrg //! Literal applied on wrong instruction format: v1: %_ = v_mul_f32 %vgpr0, 0x1234 dst_sel:dword src0_sel:dword src1_sel:dword 857ec681f3Smrg //! Wrong source position for Literal argument: v1: %_ = v_mul_f32 %vgpr0, 0x1234 dst_sel:dword src0_sel:dword src1_sel:dword 867ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_mul_f32, bld.def(v1), Operand::c32(0x1234u), inputs[1]); 877ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], Operand::c32(0x1234u)); 887ec681f3Smrg 897ec681f3Smrg //! Validation failed 907ec681f3Smrg 917ec681f3Smrg finish_validator_test(); 927ec681f3Smrg } 937ec681f3SmrgEND_TEST 947ec681f3Smrg 957ec681f3SmrgBEGIN_TEST(validate.sdwa.vopc) 967ec681f3Smrg for (unsigned i = GFX8; i <= GFX10; i++) { 977ec681f3Smrg //>> v1: %vgpr0, v1: %vgp1, s1: %sgpr0, s1: %sgpr1 = p_startpgm 987ec681f3Smrg if (!setup_cs("v1 v1 s1 s1", (chip_class)i)) 997ec681f3Smrg continue; 1007ec681f3Smrg //>> Validation results: 1017ec681f3Smrg 1027ec681f3Smrg bld.vopc_sdwa(aco_opcode::v_cmp_gt_f32, bld.def(bld.lm, vcc), inputs[0], inputs[1]); 1037ec681f3Smrg 1047ec681f3Smrg //~gfx8! SDWA+VOPC definition must be fixed to vcc on GFX8: s2: %_ = v_cmp_lt_f32 %vgpr0, %vgpr1 src0_sel:dword src1_sel:dword 1057ec681f3Smrg bld.vopc_sdwa(aco_opcode::v_cmp_lt_f32, bld.def(bld.lm), inputs[0], inputs[1]); 1067ec681f3Smrg 1077ec681f3Smrg //~gfx(9|10)! SDWA VOPC clamp only supported on GFX8: s2: %_:vcc = v_cmp_eq_f32 %vgpr0, %vgpr1 clamp src0_sel:dword src1_sel:dword 1087ec681f3Smrg bld.vopc_sdwa(aco_opcode::v_cmp_eq_f32, bld.def(bld.lm, vcc), inputs[0], inputs[1]).instr->sdwa().clamp = true; 1097ec681f3Smrg 1107ec681f3Smrg //! Validation failed 1117ec681f3Smrg 1127ec681f3Smrg finish_validator_test(); 1137ec681f3Smrg } 1147ec681f3SmrgEND_TEST 1157ec681f3Smrg 1167ec681f3SmrgBEGIN_TEST(validate.sdwa.omod) 1177ec681f3Smrg for (unsigned i = GFX8; i <= GFX10; i++) { 1187ec681f3Smrg //>> v1: %vgpr0, v1: %vgp1, s1: %sgpr0, s1: %sgpr1 = p_startpgm 1197ec681f3Smrg if (!setup_cs("v1 v1 s1 s1", (chip_class)i)) 1207ec681f3Smrg continue; 1217ec681f3Smrg //>> Validation results: 1227ec681f3Smrg 1237ec681f3Smrg //~gfx8! SDWA omod only supported on GFX9+: v1: %_ = v_mul_f32 %vgpr0, %vgpr1 *2 dst_sel:dword src0_sel:dword src1_sel:dword 1247ec681f3Smrg //~gfx8! Validation failed 1257ec681f3Smrg //~gfx(9|10)! Validation passed 1267ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]).instr->sdwa().omod = 1; 1277ec681f3Smrg 1287ec681f3Smrg finish_validator_test(); 1297ec681f3Smrg } 1307ec681f3SmrgEND_TEST 1317ec681f3Smrg 1327ec681f3SmrgBEGIN_TEST(validate.sdwa.vcc) 1337ec681f3Smrg for (unsigned i = GFX8; i <= GFX10; i++) { 1347ec681f3Smrg //>> v1: %vgpr0, v1: %vgpr1, s2: %sgpr0 = p_startpgm 1357ec681f3Smrg if (!setup_cs("v1 v1 s2", (chip_class)i)) 1367ec681f3Smrg continue; 1377ec681f3Smrg //>> Validation results: 1387ec681f3Smrg 1397ec681f3Smrg //! 3rd operand must be fixed to vcc with SDWA: v1: %_ = v_cndmask_b32 %vgpr0, %vgpr1, %_ dst_sel:dword src0_sel:dword src1_sel:dword 1407ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_cndmask_b32, bld.def(v1), inputs[0], inputs[1], inputs[2]); 1417ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_cndmask_b32, bld.def(v1), inputs[0], inputs[1], bld.vcc(inputs[2])); 1427ec681f3Smrg 1437ec681f3Smrg //! 2nd definition must be fixed to vcc with SDWA: v1: %_, s2: %_ = v_add_co_u32 %vgpr0, %vgpr1 dst_sel:dword src0_sel:dword src1_sel:dword 1447ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_add_co_u32, bld.def(v1), bld.def(bld.lm), inputs[0], inputs[1]); 1457ec681f3Smrg bld.vop2_sdwa(aco_opcode::v_add_co_u32, bld.def(v1), bld.def(bld.lm, vcc), inputs[0], inputs[1]); 1467ec681f3Smrg 1477ec681f3Smrg //! Validation failed 1487ec681f3Smrg 1497ec681f3Smrg finish_validator_test(); 1507ec681f3Smrg } 1517ec681f3SmrgEND_TEST 1527ec681f3Smrg 1537ec681f3SmrgBEGIN_TEST(optimize.sdwa.extract) 1547ec681f3Smrg for (unsigned i = GFX7; i <= GFX10; i++) { 1557ec681f3Smrg for (unsigned is_signed = 0; is_signed <= 1; is_signed++) { 1567ec681f3Smrg //>> v1: %a, v1: %b, s1: %c, s1: %d = p_startpgm 1577ec681f3Smrg if (!setup_cs("v1 v1 s1 s1", (chip_class)i, CHIP_UNKNOWN, is_signed ? "_signed" : "_unsigned")) 1587ec681f3Smrg continue; 1597ec681f3Smrg 1607ec681f3Smrg //; def standard_test(index, sel): 1617ec681f3Smrg //; res = 'v1: %%res%s = v_mul_f32 %%a, %%b dst_sel:dword src0_sel:dword src1_sel:%c%s\n' % (index, 's' if variant.endswith('_signed') else 'u', sel) 1627ec681f3Smrg //; res += 'p_unit_test %s, %%res%s' % (index, index) 1637ec681f3Smrg //; return res 1647ec681f3Smrg //; funcs['standard_test'] = lambda a: standard_test(*(v for v in a.split(','))) 1657ec681f3Smrg 1667ec681f3Smrg aco_opcode ext = aco_opcode::p_extract; 1677ec681f3Smrg aco_opcode ins = aco_opcode::p_insert; 1687ec681f3Smrg 1697ec681f3Smrg { 1707ec681f3Smrg //~gfx[^7].*! @standard_test(0,byte0) 1717ec681f3Smrg Temp bfe_byte0_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::zero(), Operand::c32(8u), 1727ec681f3Smrg Operand::c32(is_signed)); 1737ec681f3Smrg writeout(0, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], bfe_byte0_b)); 1747ec681f3Smrg 1757ec681f3Smrg //~gfx[^7].*! @standard_test(1,byte1) 1767ec681f3Smrg Temp bfe_byte1_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::c32(1u), Operand::c32(8u), 1777ec681f3Smrg Operand::c32(is_signed)); 1787ec681f3Smrg writeout(1, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], bfe_byte1_b)); 1797ec681f3Smrg 1807ec681f3Smrg //~gfx[^7].*! @standard_test(2,byte2) 1817ec681f3Smrg Temp bfe_byte2_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::c32(2u), Operand::c32(8u), 1827ec681f3Smrg Operand::c32(is_signed)); 1837ec681f3Smrg writeout(2, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], bfe_byte2_b)); 1847ec681f3Smrg 1857ec681f3Smrg //~gfx[^7].*! @standard_test(3,byte3) 1867ec681f3Smrg Temp bfe_byte3_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::c32(3u), Operand::c32(8u), 1877ec681f3Smrg Operand::c32(is_signed)); 1887ec681f3Smrg writeout(3, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], bfe_byte3_b)); 1897ec681f3Smrg 1907ec681f3Smrg //~gfx[^7].*! @standard_test(4,word0) 1917ec681f3Smrg Temp bfe_word0_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::zero(), Operand::c32(16u), 1927ec681f3Smrg Operand::c32(is_signed)); 1937ec681f3Smrg writeout(4, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], bfe_word0_b)); 1947ec681f3Smrg 1957ec681f3Smrg //~gfx[^7].*! @standard_test(5,word1) 1967ec681f3Smrg Temp bfe_word1_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::c32(1u), 1977ec681f3Smrg Operand::c32(16u), Operand::c32(is_signed)); 1987ec681f3Smrg writeout(5, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], bfe_word1_b)); 1997ec681f3Smrg 2007ec681f3Smrg //~gfx[^7]_unsigned! @standard_test(6,byte0) 2017ec681f3Smrg Temp bfi_byte0_b = bld.pseudo(ins, bld.def(v1), inputs[1], Operand::zero(), Operand::c32(8u)); 2027ec681f3Smrg writeout(6, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], bfi_byte0_b)); 2037ec681f3Smrg 2047ec681f3Smrg //~gfx[^7]_unsigned! @standard_test(7,word0) 2057ec681f3Smrg Temp bfi_word0_b = 2067ec681f3Smrg bld.pseudo(ins, bld.def(v1), inputs[1], Operand::zero(), Operand::c32(16u)); 2077ec681f3Smrg writeout(7, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], bfi_word0_b)); 2087ec681f3Smrg } 2097ec681f3Smrg 2107ec681f3Smrg //>> p_unit_test 63 2117ec681f3Smrg writeout(63); 2127ec681f3Smrg 2137ec681f3Smrg { 2147ec681f3Smrg //! v1: %tmp8 = p_insert %b, 1, 8 2157ec681f3Smrg //! v1: %res8 = v_mul_f32 %a, %tmp8 2167ec681f3Smrg //! p_unit_test 8, %res8 2177ec681f3Smrg Temp bfi_byte1_b = 2187ec681f3Smrg bld.pseudo(ins, bld.def(v1), inputs[1], Operand::c32(1u), Operand::c32(8u)); 2197ec681f3Smrg writeout(8, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], bfi_byte1_b)); 2207ec681f3Smrg 2217ec681f3Smrg /* v_cvt_f32_ubyte[0-3] can be used instead of v_cvt_f32_u32+sdwa */ 2227ec681f3Smrg //~gfx7_signed! v1: %bfe_byte0_b = p_extract %b, 0, 8, 1 2237ec681f3Smrg //~gfx7_signed! v1: %res9 = v_cvt_f32_u32 %bfe_byte0_b 2247ec681f3Smrg //~gfx[^7]+_signed! v1: %res9 = v_cvt_f32_u32 %b dst_sel:dword src0_sel:sbyte0 2257ec681f3Smrg //~gfx\d+_unsigned! v1: %res9 = v_cvt_f32_ubyte0 %b 2267ec681f3Smrg //! p_unit_test 9, %res9 2277ec681f3Smrg Temp bfe_byte0_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::zero(), Operand::c32(8u), 2287ec681f3Smrg Operand::c32(is_signed)); 2297ec681f3Smrg writeout(9, bld.vop1(aco_opcode::v_cvt_f32_u32, bld.def(v1), bfe_byte0_b)); 2307ec681f3Smrg 2317ec681f3Smrg //~gfx7_signed! v1: %bfe_byte1_b = p_extract %b, 1, 8, 1 2327ec681f3Smrg //~gfx7_signed! v1: %res10 = v_cvt_f32_u32 %bfe_byte1_b 2337ec681f3Smrg //~gfx[^7]+_signed! v1: %res10 = v_cvt_f32_u32 %b dst_sel:dword src0_sel:sbyte1 2347ec681f3Smrg //~gfx\d+_unsigned! v1: %res10 = v_cvt_f32_ubyte1 %b 2357ec681f3Smrg //! p_unit_test 10, %res10 2367ec681f3Smrg Temp bfe_byte1_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::c32(1u), Operand::c32(8u), 2377ec681f3Smrg Operand::c32(is_signed)); 2387ec681f3Smrg writeout(10, bld.vop1(aco_opcode::v_cvt_f32_u32, bld.def(v1), bfe_byte1_b)); 2397ec681f3Smrg 2407ec681f3Smrg //~gfx7_signed! v1: %bfe_byte2_b = p_extract %b, 2, 8, 1 2417ec681f3Smrg //~gfx7_signed! v1: %res11 = v_cvt_f32_u32 %bfe_byte2_b 2427ec681f3Smrg //~gfx[^7]+_signed! v1: %res11 = v_cvt_f32_u32 %b dst_sel:dword src0_sel:sbyte2 2437ec681f3Smrg //~gfx\d+_unsigned! v1: %res11 = v_cvt_f32_ubyte2 %b 2447ec681f3Smrg //! p_unit_test 11, %res11 2457ec681f3Smrg Temp bfe_byte2_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::c32(2u), Operand::c32(8u), 2467ec681f3Smrg Operand::c32(is_signed)); 2477ec681f3Smrg writeout(11, bld.vop1(aco_opcode::v_cvt_f32_u32, bld.def(v1), bfe_byte2_b)); 2487ec681f3Smrg 2497ec681f3Smrg //~gfx7_signed! v1: %bfe_byte3_b = p_extract %b, 3, 8, 1 2507ec681f3Smrg //~gfx7_signed! v1: %res12 = v_cvt_f32_u32 %bfe_byte3_b 2517ec681f3Smrg //~gfx[^7]+_signed! v1: %res12 = v_cvt_f32_u32 %b dst_sel:dword src0_sel:sbyte3 2527ec681f3Smrg //~gfx\d+_unsigned! v1: %res12 = v_cvt_f32_ubyte3 %b 2537ec681f3Smrg //! p_unit_test 12, %res12 2547ec681f3Smrg Temp bfe_byte3_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::c32(3u), Operand::c32(8u), 2557ec681f3Smrg Operand::c32(is_signed)); 2567ec681f3Smrg writeout(12, bld.vop1(aco_opcode::v_cvt_f32_u32, bld.def(v1), bfe_byte3_b)); 2577ec681f3Smrg 2587ec681f3Smrg //! v1: %res13 = v_add_i16 %a, %b 2597ec681f3Smrg //! p_unit_test 13, %res13 2607ec681f3Smrg Temp bfe_word0_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::zero(), Operand::c32(16u), 2617ec681f3Smrg Operand::c32(is_signed)); 2627ec681f3Smrg writeout(13, bld.vop3(aco_opcode::v_add_i16, bld.def(v1), inputs[0], bfe_word0_b)); 2637ec681f3Smrg 2647ec681f3Smrg /* VOP3-only instructions can't use SDWA but they can use opsel instead */ 2657ec681f3Smrg //~gfx(9|10).*! v1: %res14 = v_add_i16 %a, hi(%b) 2667ec681f3Smrg //~gfx(9|10).*! p_unit_test 14, %res14 2677ec681f3Smrg Temp bfe_word1_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::c32(1u), 2687ec681f3Smrg Operand::c32(16u), Operand::c32(is_signed)); 2697ec681f3Smrg writeout(14, bld.vop3(aco_opcode::v_add_i16, bld.def(v1), inputs[0], bfe_word1_b)); 2707ec681f3Smrg } 2717ec681f3Smrg 2727ec681f3Smrg finish_opt_test(); 2737ec681f3Smrg } 2747ec681f3Smrg } 2757ec681f3SmrgEND_TEST 2767ec681f3Smrg 2777ec681f3SmrgBEGIN_TEST(optimize.sdwa.extract_modifiers) 2787ec681f3Smrg for (unsigned i = GFX8; i <= GFX10; i++) { 2797ec681f3Smrg //>> v1: %a, v1: %b, s1: %c, s1: %d = p_startpgm 2807ec681f3Smrg if (!setup_cs("v1 v1 s1 s1", (chip_class)i)) 2817ec681f3Smrg continue; 2827ec681f3Smrg 2837ec681f3Smrg aco_opcode ext = aco_opcode::p_extract; 2847ec681f3Smrg 2857ec681f3Smrg //! v1: %res0 = v_mul_f32 %a, -%b dst_sel:dword src0_sel:dword src1_sel:ubyte0 2867ec681f3Smrg //! p_unit_test 0, %res0 2877ec681f3Smrg Temp byte0 = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::zero(), Operand::c32(8u), 2887ec681f3Smrg Operand::zero()); 2897ec681f3Smrg Temp neg_byte0 = fneg(byte0); 2907ec681f3Smrg writeout(0, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], neg_byte0)); 2917ec681f3Smrg 2927ec681f3Smrg //~gfx8! v1: %neg = v_mul_f32 -1.0, %b 2937ec681f3Smrg //~gfx8! v1: %res1 = v_mul_f32 %a, %neg dst_sel:dword src0_sel:dword src1_sel:ubyte0 2947ec681f3Smrg //~gfx(9|10)! v1: %neg_byte0 = v_mul_f32 -1.0, %b dst_sel:ubyte0 src0_sel:dword src1_sel:dword 2957ec681f3Smrg //~gfx(9|10)! v1: %res1 = v_mul_f32 %a, %neg_byte0 2967ec681f3Smrg //! p_unit_test 1, %res1 2977ec681f3Smrg Temp neg = fneg(inputs[1]); 2987ec681f3Smrg Temp byte0_neg = 2997ec681f3Smrg bld.pseudo(ext, bld.def(v1), neg, Operand::zero(), Operand::c32(8u), Operand::zero()); 3007ec681f3Smrg writeout(1, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], byte0_neg)); 3017ec681f3Smrg 3027ec681f3Smrg //! v1: %res2 = v_mul_f32 %a, |%b| dst_sel:dword src0_sel:dword src1_sel:ubyte0 3037ec681f3Smrg //! p_unit_test 2, %res2 3047ec681f3Smrg Temp abs_byte0 = fabs(byte0); 3057ec681f3Smrg writeout(2, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], abs_byte0)); 3067ec681f3Smrg 3077ec681f3Smrg //! v1: %abs = v_mul_f32 1.0, |%b| 3087ec681f3Smrg //! v1: %res3 = v_mul_f32 %a, %abs dst_sel:dword src0_sel:dword src1_sel:ubyte0 3097ec681f3Smrg //! p_unit_test 3, %res3 3107ec681f3Smrg Temp abs = fabs(inputs[1]); 3117ec681f3Smrg Temp byte0_abs = 3127ec681f3Smrg bld.pseudo(ext, bld.def(v1), abs, Operand::zero(), Operand::c32(8u), Operand::zero()); 3137ec681f3Smrg writeout(3, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], byte0_abs)); 3147ec681f3Smrg 3157ec681f3Smrg //! v1: %res4 = v_mul_f32 %1, -|%2| dst_sel:dword src0_sel:dword src1_sel:ubyte0 3167ec681f3Smrg //! p_unit_test 4, %res4 3177ec681f3Smrg Temp neg_abs_byte0 = fneg(abs_byte0); 3187ec681f3Smrg writeout(4, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], neg_abs_byte0)); 3197ec681f3Smrg 3207ec681f3Smrg //~gfx8! v1: %neg_abs = v_mul_f32 -1.0, %abs 3217ec681f3Smrg //~gfx8! v1: %res5 = v_mul_f32 %a, %neg_abs dst_sel:dword src0_sel:dword src1_sel:ubyte0 3227ec681f3Smrg //~gfx(9|10)! v1: %neg_abs_byte0 = v_mul_f32 -1.0, %abs dst_sel:ubyte0 src0_sel:dword src1_sel:dword 3237ec681f3Smrg //~gfx(9|10)! v1: %res5 = v_mul_f32 %a, %neg_abs_byte0 3247ec681f3Smrg //! p_unit_test 5, %res5 3257ec681f3Smrg Temp neg_abs = fneg(abs); 3267ec681f3Smrg Temp byte0_neg_abs = 3277ec681f3Smrg bld.pseudo(ext, bld.def(v1), neg_abs, Operand::zero(), Operand::c32(8u), Operand::zero()); 3287ec681f3Smrg writeout(5, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], byte0_neg_abs)); 3297ec681f3Smrg 3307ec681f3Smrg finish_opt_test(); 3317ec681f3Smrg } 3327ec681f3SmrgEND_TEST 3337ec681f3Smrg 3347ec681f3SmrgBEGIN_TEST(optimize.sdwa.extract.sgpr) 3357ec681f3Smrg for (unsigned i = GFX8; i <= GFX10; i++) { 3367ec681f3Smrg //>> v1: %a, v1: %b, s1: %c, s1: %d = p_startpgm 3377ec681f3Smrg if (!setup_cs("v1 v1 s1 s1", (chip_class)i)) 3387ec681f3Smrg continue; 3397ec681f3Smrg 3407ec681f3Smrg aco_opcode ext = aco_opcode::p_extract; 3417ec681f3Smrg 3427ec681f3Smrg //~gfx8! v1: %byte0_b = p_extract %b, 0, 8, 0 3437ec681f3Smrg //~gfx8! v1: %res1 = v_mul_f32 %c, %byte0_b 3447ec681f3Smrg //~gfx(9|10)! v1: %res1 = v_mul_f32 %c, %b dst_sel:dword src0_sel:dword src1_sel:ubyte0 3457ec681f3Smrg //! p_unit_test 1, %res1 3467ec681f3Smrg Temp byte0_b = bld.pseudo(ext, bld.def(v1), inputs[1], Operand::zero(), Operand::c32(8u), 3477ec681f3Smrg Operand::zero()); 3487ec681f3Smrg writeout(1, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[2], byte0_b)); 3497ec681f3Smrg 3507ec681f3Smrg //~gfx8! v1: %byte0_c = p_extract %c, 0, 8, 0 3517ec681f3Smrg //~gfx8! v1: %res2 = v_mul_f32 %a, %byte0_c 3527ec681f3Smrg //~gfx(9|10)! v1: %res2 = v_mul_f32 %a, %c dst_sel:dword src0_sel:dword src1_sel:ubyte0 3537ec681f3Smrg //! p_unit_test 2, %res2 3547ec681f3Smrg Temp byte0_c = bld.pseudo(ext, bld.def(v1), inputs[2], Operand::zero(), Operand::c32(8u), 3557ec681f3Smrg Operand::zero()); 3567ec681f3Smrg writeout(2, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], byte0_c)); 3577ec681f3Smrg 3587ec681f3Smrg //~gfx8! v1: %byte0_c_2 = p_extract %c, 0, 8, 0 3597ec681f3Smrg //~gfx8! v1: %res3 = v_mul_f32 %c, %byte0_c_2 3607ec681f3Smrg //~gfx(9|10)! v1: %res3 = v_mul_f32 %c, %c dst_sel:dword src0_sel:dword src1_sel:ubyte0 3617ec681f3Smrg //! p_unit_test 3, %res3 3627ec681f3Smrg byte0_c = bld.pseudo(ext, bld.def(v1), inputs[2], Operand::zero(), Operand::c32(8u), 3637ec681f3Smrg Operand::zero()); 3647ec681f3Smrg writeout(3, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[2], byte0_c)); 3657ec681f3Smrg 3667ec681f3Smrg //~gfx(8|9)! v1: %byte0_c_3 = p_extract %c, 0, 8, 0 3677ec681f3Smrg //~gfx(8|9)! v1: %res4 = v_mul_f32 %d, %byte0_c_3 3687ec681f3Smrg //~gfx10! v1: %res4 = v_mul_f32 %d, %c dst_sel:dword src0_sel:dword src1_sel:ubyte0 3697ec681f3Smrg //! p_unit_test 4, %res4 3707ec681f3Smrg byte0_c = bld.pseudo(ext, bld.def(v1), inputs[2], Operand::zero(), Operand::c32(8u), 3717ec681f3Smrg Operand::zero()); 3727ec681f3Smrg writeout(4, bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[3], byte0_c)); 3737ec681f3Smrg 3747ec681f3Smrg finish_opt_test(); 3757ec681f3Smrg } 3767ec681f3SmrgEND_TEST 3777ec681f3Smrg 3787ec681f3SmrgBEGIN_TEST(optimize.sdwa.from_vop3) 3797ec681f3Smrg for (unsigned i = GFX8; i <= GFX10; i++) { 3807ec681f3Smrg //>> v1: %a, v1: %b, s1: %c, s1: %d = p_startpgm 3817ec681f3Smrg if (!setup_cs("v1 v1 s1 s1", (chip_class)i)) 3827ec681f3Smrg continue; 3837ec681f3Smrg 3847ec681f3Smrg //! v1: %res0 = v_mul_f32 -|%a|, %b dst_sel:dword src0_sel:dword src1_sel:ubyte0 3857ec681f3Smrg //! p_unit_test 0, %res0 3867ec681f3Smrg Temp byte0_b = bld.pseudo(aco_opcode::p_extract, bld.def(v1), inputs[1], Operand::zero(), 3877ec681f3Smrg Operand::c32(8u), Operand::zero()); 3887ec681f3Smrg VOP3_instruction *mul = &bld.vop2_e64(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], byte0_b).instr->vop3(); 3897ec681f3Smrg mul->neg[0] = true; 3907ec681f3Smrg mul->abs[0] = true; 3917ec681f3Smrg writeout(0, mul->definitions[0].getTemp()); 3927ec681f3Smrg 3937ec681f3Smrg //~gfx8! v1: %byte0_b_0 = p_extract %b, 0, 8, 0 3947ec681f3Smrg //~gfx8! v1: %res1 = v_mul_f32 %a, %byte0_b_0 *4 3957ec681f3Smrg //~gfx(9|10)! v1: %res1 = v_mul_f32 %a, %b *4 dst_sel:dword src0_sel:dword src1_sel:ubyte0 3967ec681f3Smrg //! p_unit_test 1, %res1 3977ec681f3Smrg byte0_b = bld.pseudo(aco_opcode::p_extract, bld.def(v1), inputs[1], Operand::zero(), 3987ec681f3Smrg Operand::c32(8u), Operand::zero()); 3997ec681f3Smrg mul = &bld.vop2_e64(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], byte0_b).instr->vop3(); 4007ec681f3Smrg mul->omod = 2; 4017ec681f3Smrg writeout(1, mul->definitions[0].getTemp()); 4027ec681f3Smrg 4037ec681f3Smrg //~gfx8! v1: %byte0_b_1 = p_extract %b, 0, 8, 0 4047ec681f3Smrg //~gfx8! v1: %res2 = v_mul_f32 %byte0_b_1, %c 4057ec681f3Smrg //~gfx(9|10)! v1: %res2 = v_mul_f32 %b, %c dst_sel:dword src0_sel:ubyte0 src1_sel:dword 4067ec681f3Smrg //! p_unit_test 2, %res2 4077ec681f3Smrg byte0_b = bld.pseudo(aco_opcode::p_extract, bld.def(v1), inputs[1], Operand::zero(), 4087ec681f3Smrg Operand::c32(8u), Operand::zero()); 4097ec681f3Smrg writeout(2, bld.vop2_e64(aco_opcode::v_mul_f32, bld.def(v1), byte0_b, inputs[2])); 4107ec681f3Smrg 4117ec681f3Smrg if (i >= GFX10) { 4127ec681f3Smrg //~gfx10! v1: %byte0_b_2 = p_extract %b, 0, 8, 0 4137ec681f3Smrg //~gfx10! v1: %res3 = v_mul_f32 %byte0_b_2, 0x1234 4147ec681f3Smrg //~gfx10! p_unit_test 3, %res3 4157ec681f3Smrg byte0_b = bld.pseudo(aco_opcode::p_extract, bld.def(v1), inputs[1], Operand::zero(), 4167ec681f3Smrg Operand::c32(8u), Operand::zero()); 4177ec681f3Smrg writeout(3, 4187ec681f3Smrg bld.vop2_e64(aco_opcode::v_mul_f32, bld.def(v1), byte0_b, Operand::c32(0x1234u))); 4197ec681f3Smrg } 4207ec681f3Smrg 4217ec681f3Smrg finish_opt_test(); 4227ec681f3Smrg } 4237ec681f3SmrgEND_TEST 4247ec681f3Smrg 4257ec681f3SmrgBEGIN_TEST(optimize.sdwa.insert) 4267ec681f3Smrg for (unsigned i = GFX7; i <= GFX10; i++) { 4277ec681f3Smrg //>> v1: %a, v1: %b = p_startpgm 4287ec681f3Smrg if (!setup_cs("v1 v1", (chip_class)i)) 4297ec681f3Smrg continue; 4307ec681f3Smrg 4317ec681f3Smrg aco_opcode ext = aco_opcode::p_extract; 4327ec681f3Smrg aco_opcode ins = aco_opcode::p_insert; 4337ec681f3Smrg 4347ec681f3Smrg //~gfx[^7]! v1: %res0 = v_mul_f32 %a, %b dst_sel:ubyte0 src0_sel:dword src1_sel:dword 4357ec681f3Smrg //~gfx[^7]! p_unit_test 0, %res0 4367ec681f3Smrg Temp val = bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 4377ec681f3Smrg writeout(0, bld.pseudo(ins, bld.def(v1), val, Operand::zero(), Operand::c32(8u))); 4387ec681f3Smrg 4397ec681f3Smrg //~gfx[^7]! v1: %res1 = v_mul_f32 %a, %b dst_sel:ubyte1 src0_sel:dword src1_sel:dword 4407ec681f3Smrg //~gfx[^7]! p_unit_test 1, %res1 4417ec681f3Smrg val = bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 4427ec681f3Smrg writeout(1, bld.pseudo(ins, bld.def(v1), val, Operand::c32(1u), Operand::c32(8u))); 4437ec681f3Smrg 4447ec681f3Smrg //~gfx[^7]! v1: %res2 = v_mul_f32 %a, %b dst_sel:ubyte2 src0_sel:dword src1_sel:dword 4457ec681f3Smrg //~gfx[^7]! p_unit_test 2, %res2 4467ec681f3Smrg val = bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 4477ec681f3Smrg writeout(2, bld.pseudo(ins, bld.def(v1), val, Operand::c32(2u), Operand::c32(8u))); 4487ec681f3Smrg 4497ec681f3Smrg //~gfx[^7]! v1: %res3 = v_mul_f32 %a, %b dst_sel:ubyte3 src0_sel:dword src1_sel:dword 4507ec681f3Smrg //~gfx[^7]! p_unit_test 3, %res3 4517ec681f3Smrg val = bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 4527ec681f3Smrg writeout(3, bld.pseudo(ins, bld.def(v1), val, Operand::c32(3u), Operand::c32(8u))); 4537ec681f3Smrg 4547ec681f3Smrg //~gfx[^7]! v1: %res4 = v_mul_f32 %a, %b dst_sel:uword0 src0_sel:dword src1_sel:dword 4557ec681f3Smrg //~gfx[^7]! p_unit_test 4, %res4 4567ec681f3Smrg val = bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 4577ec681f3Smrg writeout(4, bld.pseudo(ins, bld.def(v1), val, Operand::zero(), Operand::c32(16u))); 4587ec681f3Smrg 4597ec681f3Smrg //~gfx[^7]! v1: %res5 = v_mul_f32 %a, %b dst_sel:uword1 src0_sel:dword src1_sel:dword 4607ec681f3Smrg //~gfx[^7]! p_unit_test 5, %res5 4617ec681f3Smrg val = bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 4627ec681f3Smrg writeout(5, bld.pseudo(ins, bld.def(v1), val, Operand::c32(1u), Operand::c32(16u))); 4637ec681f3Smrg 4647ec681f3Smrg //~gfx[^7]! v1: %res6 = v_mul_f32 %a, %b dst_sel:ubyte0 src0_sel:dword src1_sel:dword 4657ec681f3Smrg //~gfx[^7]! p_unit_test 6, %res6 4667ec681f3Smrg val = bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 4677ec681f3Smrg writeout( 4687ec681f3Smrg 6, bld.pseudo(ext, bld.def(v1), val, Operand::zero(), Operand::c32(8u), Operand::zero())); 4697ec681f3Smrg 4707ec681f3Smrg //~gfx[^7]! v1: %res7 = v_mul_f32 %a, %b dst_sel:uword0 src0_sel:dword src1_sel:dword 4717ec681f3Smrg //~gfx[^7]! p_unit_test 7, %res7 4727ec681f3Smrg val = bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 4737ec681f3Smrg writeout( 4747ec681f3Smrg 7, bld.pseudo(ext, bld.def(v1), val, Operand::zero(), Operand::c32(16u), Operand::zero())); 4757ec681f3Smrg 4767ec681f3Smrg //~gfx[^7]! v1: %tmp8 = v_mul_f32 %a, %b 4777ec681f3Smrg //~gfx[^7]! v1: %res8 = p_extract %tmp8, 2, 8, 0 4787ec681f3Smrg //~gfx[^7]! p_unit_test 8, %res8 4797ec681f3Smrg val = bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 4807ec681f3Smrg writeout( 4817ec681f3Smrg 8, bld.pseudo(ext, bld.def(v1), val, Operand::c32(2u), Operand::c32(8u), Operand::zero())); 4827ec681f3Smrg 4837ec681f3Smrg //~gfx[^7]! v1: %tmp9 = v_mul_f32 %a, %b 4847ec681f3Smrg //~gfx[^7]! v1: %res9 = p_extract %tmp9, 0, 8, 1 4857ec681f3Smrg //~gfx[^7]! p_unit_test 9, %res9 4867ec681f3Smrg val = bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 4877ec681f3Smrg writeout( 4887ec681f3Smrg 9, bld.pseudo(ext, bld.def(v1), val, Operand::zero(), Operand::c32(8u), Operand::c32(1u))); 4897ec681f3Smrg 4907ec681f3Smrg //>> p_unit_test 63 4917ec681f3Smrg writeout(63); 4927ec681f3Smrg 4937ec681f3Smrg //! v1: %res10 = v_mul_f32 %a, %b 4947ec681f3Smrg //! p_unit_test 10, %res10 4957ec681f3Smrg val = bld.vop2(aco_opcode::v_mul_f32, bld.def(v1), inputs[0], inputs[1]); 4967ec681f3Smrg bld.pseudo(ins, bld.def(v1), val, Operand::c32(1u), Operand::c32(16u)); 4977ec681f3Smrg writeout(10, val); 4987ec681f3Smrg 4997ec681f3Smrg //! v1: %res11 = v_sub_i16 %a, %b 5007ec681f3Smrg //! p_unit_test 11, %res11 5017ec681f3Smrg val = bld.vop3(aco_opcode::v_sub_i16, bld.def(v1), inputs[0], inputs[1]); 5027ec681f3Smrg writeout(11, bld.pseudo(ins, bld.def(v1), val, Operand::zero(), Operand::c32(16u))); 5037ec681f3Smrg 5047ec681f3Smrg //~gfx[78]! v1: %tmp12 = v_sub_i16 %a, %b 5057ec681f3Smrg //~gfx[78]! v1: %res12 = p_insert %tmp11, 1, 16 5067ec681f3Smrg //~gfx(9|10)! v1: %res12 = v_sub_i16 %a, %b opsel_hi 5077ec681f3Smrg //! p_unit_test 12, %res12 5087ec681f3Smrg val = bld.vop3(aco_opcode::v_sub_i16, bld.def(v1), inputs[0], inputs[1]); 5097ec681f3Smrg writeout(12, bld.pseudo(ins, bld.def(v1), val, Operand::c32(1u), Operand::c32(16u))); 5107ec681f3Smrg 5117ec681f3Smrg //! v1: %tmp13 = v_sub_i16 %a, %b 5127ec681f3Smrg //! v1: %res13 = p_insert %tmp13, 0, 8 5137ec681f3Smrg //! p_unit_test 13, %res13 5147ec681f3Smrg val = bld.vop3(aco_opcode::v_sub_i16, bld.def(v1), inputs[0], inputs[1]); 5157ec681f3Smrg writeout(13, bld.pseudo(ins, bld.def(v1), val, Operand::zero(), Operand::c32(8u))); 5167ec681f3Smrg 5177ec681f3Smrg finish_opt_test(); 5187ec681f3Smrg } 5197ec681f3SmrgEND_TEST 5207ec681f3Smrg 5217ec681f3SmrgBEGIN_TEST(optimize.sdwa.insert_modifiers) 5227ec681f3Smrg for (unsigned i = GFX8; i <= GFX9; i++) { 5237ec681f3Smrg //>> v1: %a = p_startpgm 5247ec681f3Smrg if (!setup_cs("v1", (chip_class)i)) 5257ec681f3Smrg continue; 5267ec681f3Smrg 5277ec681f3Smrg aco_opcode ins = aco_opcode::p_insert; 5287ec681f3Smrg 5297ec681f3Smrg //~gfx8! v1: %tmp0 = v_rcp_f32 %a *2 5307ec681f3Smrg //~gfx8! v1: %res0 = p_insert %tmp0, 0, 8 5317ec681f3Smrg //~gfx9! v1: %res0 = v_rcp_f32 %a *2 dst_sel:ubyte0 src0_sel:dword 5327ec681f3Smrg //! p_unit_test 0, %res0 5337ec681f3Smrg Temp val = bld.vop1(aco_opcode::v_rcp_f32, bld.def(v1), inputs[0]); 5347ec681f3Smrg val = bld.vop2_e64(aco_opcode::v_mul_f32, bld.def(v1), val, Operand::c32(0x40000000u)); 5357ec681f3Smrg writeout(0, bld.pseudo(ins, bld.def(v1), val, Operand::zero(), Operand::c32(8u))); 5367ec681f3Smrg 5377ec681f3Smrg //! v1: %res1 = v_rcp_f32 %a clamp dst_sel:ubyte0 src0_sel:dword 5387ec681f3Smrg //! p_unit_test 1, %res1 5397ec681f3Smrg val = bld.vop1(aco_opcode::v_rcp_f32, bld.def(v1), inputs[0]); 5407ec681f3Smrg val = bld.vop3(aco_opcode::v_med3_f32, bld.def(v1), val, Operand::zero(), 5417ec681f3Smrg Operand::c32(0x3f800000u)); 5427ec681f3Smrg writeout(1, bld.pseudo(ins, bld.def(v1), val, Operand::zero(), Operand::c32(8u))); 5437ec681f3Smrg 5447ec681f3Smrg //! v1: %tmp2 = v_rcp_f32 %a dst_sel:ubyte0 src0_sel:dword 5457ec681f3Smrg //! v1: %res2 = v_mul_f32 %tmp2, 2.0 5467ec681f3Smrg //! p_unit_test 2, %res2 5477ec681f3Smrg val = bld.vop1(aco_opcode::v_rcp_f32, bld.def(v1), inputs[0]); 5487ec681f3Smrg val = bld.pseudo(ins, bld.def(v1), val, Operand::zero(), Operand::c32(8u)); 5497ec681f3Smrg val = bld.vop2_e64(aco_opcode::v_mul_f32, bld.def(v1), val, Operand::c32(0x40000000u)); 5507ec681f3Smrg writeout(2, val); 5517ec681f3Smrg 5527ec681f3Smrg //! v1: %tmp3 = v_rcp_f32 %a dst_sel:ubyte0 src0_sel:dword 5537ec681f3Smrg //! v1: %res3 = v_med3_f32 %tmp3, 0, 1.0 5547ec681f3Smrg //! p_unit_test 3, %res3 5557ec681f3Smrg val = bld.vop1(aco_opcode::v_rcp_f32, bld.def(v1), inputs[0]); 5567ec681f3Smrg val = bld.pseudo(ins, bld.def(v1), val, Operand::zero(), Operand::c32(8u)); 5577ec681f3Smrg val = bld.vop3(aco_opcode::v_med3_f32, bld.def(v1), val, Operand::zero(), 5587ec681f3Smrg Operand::c32(0x3f800000u)); 5597ec681f3Smrg writeout(3, val); 5607ec681f3Smrg 5617ec681f3Smrg //~gfx8! v1: %tmp4 = v_rcp_f32 %a *2 clamp 5627ec681f3Smrg //~gfx8! v1: %res4 = p_insert %tmp4, 0, 8 5637ec681f3Smrg //~gfx9! v1: %res4 = v_rcp_f32 %a *2 clamp dst_sel:ubyte0 src0_sel:dword 5647ec681f3Smrg //! p_unit_test 4, %res4 5657ec681f3Smrg val = bld.vop1(aco_opcode::v_rcp_f32, bld.def(v1), inputs[0]); 5667ec681f3Smrg val = bld.vop2_e64(aco_opcode::v_mul_f32, bld.def(v1), val, Operand::c32(0x40000000u)); 5677ec681f3Smrg val = bld.vop3(aco_opcode::v_med3_f32, bld.def(v1), val, Operand::zero(), 5687ec681f3Smrg Operand::c32(0x3f800000u)); 5697ec681f3Smrg writeout(4, bld.pseudo(ins, bld.def(v1), val, Operand::zero(), Operand::c32(8u))); 5707ec681f3Smrg 5717ec681f3Smrg finish_opt_test(); 5727ec681f3Smrg } 5737ec681f3SmrgEND_TEST 574