nir/vtn: SPIR-V bit count opcodes (core and extension) dest size mismatches nir
[mesa.git] / src / compiler / spirv / vtn_opencl.c
index a4eb41d241bf5e9745cd6843c46618ff54c6b6e0..b5e92dc3b85e1d53ccb321747bf8e74ec2201c73 100644 (file)
@@ -117,8 +117,11 @@ handle_alu(struct vtn_builder *b, enum OpenCLstd_Entrypoints opcode,
            unsigned num_srcs, nir_ssa_def **srcs,
            const struct glsl_type *dest_type)
 {
-   return nir_build_alu(&b->nb, nir_alu_op_for_opencl_opcode(b, opcode),
-                        srcs[0], srcs[1], srcs[2], NULL);
+   nir_ssa_def *ret = nir_build_alu(&b->nb, nir_alu_op_for_opencl_opcode(b, opcode),
+                                    srcs[0], srcs[1], srcs[2], NULL);
+   if (opcode == OpenCLstd_Popcount)
+      ret = nir_u2u(&b->nb, ret, glsl_get_bit_size(dest_type));
+   return ret;
 }
 
 static nir_ssa_def *