aco/ra: Static assert that changing instruction type to VOP2 is valid.
authorGeorg Lehmann <dadschoorse@gmail.com>
Sun, 17 Apr 2022 19:17:18 +0000 (21:17 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 6 Jul 2022 09:54:54 +0000 (09:54 +0000)
It's not obvious that this is correct.

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15999>

src/amd/compiler/aco_register_allocation.cpp

index 6193e4b..922c5b8 100644 (file)
@@ -2695,6 +2695,10 @@ register_allocation(Program* program, std::vector<IDSet>& live_out_per_block, ra
                   use_vop2 = false;
             }
             if (use_vop2) {
+               static_assert(sizeof(VOP2_instruction) <= sizeof(VOP3_instruction),
+                             "Invalid direct instruction cast.");
+               static_assert(sizeof(VOP2_instruction) <= sizeof(VOP3P_instruction),
+                             "Invalid direct instruction cast.");
                instr->format = Format::VOP2;
                switch (instr->opcode) {
                case aco_opcode::v_mad_f32: instr->opcode = aco_opcode::v_mac_f32; break;