aco/tests: add disassembler tests to reproduce the add3+clamp crash
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 1 Oct 2020 08:11:33 +0000 (10:11 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 2 Oct 2020 12:21:33 +0000 (14:21 +0200)
Like some other v_add instructions, LLVM fails to disassemble
v_add3_u32 + clamp.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6961>

src/amd/compiler/tests/test_assembler.cpp

index ae4247e..23f02dd 100644 (file)
@@ -227,3 +227,40 @@ BEGIN_TEST(assembler.long_jump.constaddr)
 
    finish_assembler_test();
 END_TEST
+
+BEGIN_TEST(assembler.v_add3)
+   for (unsigned i = GFX9; i <= GFX10; i++) {
+      if (!setup_cs(NULL, (chip_class)i))
+         continue;
+
+      //~gfx9>> v_add3_u32 v0, 0, 0, 0 ; d1ff0000 02010080
+      //~gfx10>> v_add3_u32 v0, 0, 0, 0 ; d76d0000 02010080
+      aco_ptr<VOP3A_instruction> add3{create_instruction<VOP3A_instruction>(aco_opcode::v_add3_u32, Format::VOP3A, 3, 1)};
+      add3->operands[0] = Operand(0u);
+      add3->operands[1] = Operand(0u);
+      add3->operands[2] = Operand(0u);
+      add3->definitions[0] = Definition(PhysReg(0), v1);
+      bld.insert(std::move(add3));
+
+      finish_assembler_test();
+   }
+END_TEST
+
+BEGIN_TEST(assembler.v_add3_clamp)
+   for (unsigned i = GFX9; i <= GFX10; i++) {
+      if (!setup_cs(NULL, (chip_class)i))
+         continue;
+
+      //~gfx9>> integer addition + clamp ; d1ff8000 02010080
+      //~gfx10>> integer addition + clamp ; d76d8000 02010080
+      aco_ptr<VOP3A_instruction> add3{create_instruction<VOP3A_instruction>(aco_opcode::v_add3_u32, Format::VOP3A, 3, 1)};
+      add3->operands[0] = Operand(0u);
+      add3->operands[1] = Operand(0u);
+      add3->operands[2] = Operand(0u);
+      add3->definitions[0] = Definition(PhysReg(0), v1);
+      add3->clamp = 1;
+      bld.insert(std::move(add3));
+
+      finish_assembler_test();
+   }
+END_TEST