Mesa (master): nir: Make the nir_builder *_imm helpers consistently handle bit size.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Aug 24 17:15:14 UTC 2020
Module: Mesa
Branch: master
Commit: e78b887f76706ed0667457079474c31ac08374d0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e78b887f76706ed0667457079474c31ac08374d0
Author: Eric Anholt <eric at anholt.net>
Date: Fri Aug 21 11:15:24 2020 -0700
nir: Make the nir_builder *_imm helpers consistently handle bit size.
We always want to demote the y to the bit size of the ssa def, but also
want to sanity check that our input and our masking is big enough.
Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6378>
---
src/compiler/nir/nir_builder.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 31801adbc3c..73c09583820 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -708,8 +708,7 @@ static inline nir_ssa_def *
nir_iadd_imm(nir_builder *build, nir_ssa_def *x, uint64_t y)
{
assert(x->bit_size <= 64);
- if (x->bit_size < 64)
- y &= (1ull << x->bit_size) - 1;
+ y &= BITFIELD64_MASK(x->bit_size);
if (y == 0) {
return x;
@@ -722,8 +721,7 @@ static inline nir_ssa_def *
_nir_mul_imm(nir_builder *build, nir_ssa_def *x, uint64_t y, bool amul)
{
assert(x->bit_size <= 64);
- if (x->bit_size < 64)
- y &= (1ull << x->bit_size) - 1;
+ y &= BITFIELD64_MASK(x->bit_size);
if (y == 0) {
return nir_imm_intN_t(build, 0, x->bit_size);
@@ -766,6 +764,7 @@ nir_fmul_imm(nir_builder *build, nir_ssa_def *x, double y)
static inline nir_ssa_def *
nir_iand_imm(nir_builder *build, nir_ssa_def *x, uint64_t y)
{
+ assert(x->bit_size <= 64);
y &= BITFIELD64_MASK(x->bit_size);
if (y == 0) {
More information about the mesa-commit
mailing list