aco: fix validation of opsel when set for the definition
authorRhys Perry <pendingchaos02@gmail.com>
Wed, 17 Jun 2020 13:50:10 +0000 (14:50 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 17 Jun 2020 15:48:35 +0000 (15:48 +0000)
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/5521>

src/amd/compiler/aco_validate.cpp

index 90272433f858101444492bfb1b8f607eeb502084..b7c773ca8f641073251ce8ac12fe23f68ffda553 100644 (file)
@@ -159,11 +159,11 @@ void validate(Program* program, FILE * output)
          if (instr->isVOP3()) {
             VOP3A_instruction *vop3 = static_cast<VOP3A_instruction*>(instr.get());
             check(vop3->opsel == 0 || program->chip_class >= GFX9, "Opsel is only supported on GFX9+", instr.get());
-            check((vop3->opsel & ~(0x10 | ((1 << instr->operands.size()) - 1))) == 0, "Unused bits in opsel must be zeroed out", instr.get());
 
-            for (unsigned i = 0; i < instr->operands.size(); i++) {
-               if (instr->operands[i].hasRegClass() && instr->operands[i].regClass().is_subdword() && !instr->operands[i].isFixed())
-                  check((vop3->opsel & (1 << i)) == 0, "Unexpected opsel for sub-dword operand", instr.get());
+            for (unsigned i = 0; i < 3; i++) {
+               if (i >= instr->operands.size() ||
+                   (instr->operands[i].hasRegClass() && instr->operands[i].regClass().is_subdword() && !instr->operands[i].isFixed()))
+                  check((vop3->opsel & (1 << i)) == 0, "Unexpected opsel for operand", instr.get());
             }
             if (instr->definitions[0].regClass().is_subdword() && !instr->definitions[0].isFixed())
                check((vop3->opsel & (1 << 3)) == 0, "Unexpected opsel for sub-dword definition", instr.get());