This assert won't catch all mistakes with this helper but it will at least ensure that the top bits are all zero or all one which should help catch bugs. --- src/compiler/nir/nir_builder.h | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 3271a480520..3be630ab3dd 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -330,6 +330,10 @@ nir_imm_intN_t(nir_builder *build, uint64_t x, unsigned bit_size) { nir_const_value v; + assert(bit_size == 64 || + (int64_t)x >> bit_size == 0 || + (int64_t)x >> bit_size == -1); + memset(&v, 0, sizeof(v)); assert(bit_size <= 64); v.i64[0] = x & (~0ull >> (64 - bit_size)); -- 2.19.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev