nir/serialize: cast swizzle before shifting
authorKarol Herbst <kherbst@redhat.com>
Wed, 11 Dec 2019 15:01:15 +0000 (16:01 +0100)
committerKarol Herbst <karolherbst@gmail.com>
Sat, 21 Dec 2019 11:00:16 +0000 (11:00 +0000)
fixes undefined behaviour with enabled vec16

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/compiler/nir/nir_serialize.c

index 49a353d4e108c912781c6828f56e33ac1bc354b8..b991b1d02e250b93303cb911416adf140142b788 100644 (file)
@@ -879,7 +879,7 @@ write_alu(write_ctx *ctx, const nir_alu_instr *alu)
                unsigned value = 0;
 
                for (unsigned j = 0; j < 8 && o + j < src_channels; j++) {
-                  value |= alu->src[i].swizzle[o + j] <<
+                  value |= (uint32_t)alu->src[i].swizzle[o + j] <<
                            (4 * j); /* 4 bits per swizzle */
                }