summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Legg <[email protected]>2017-12-06 11:55:14 +0000
committerAlex Smith <[email protected]>2017-12-07 08:59:36 +0000
commit947470d10ba5ab11a75f0e19e124b189ff3fd8b2 (patch)
tree80823c324958741784077e5ad6856cf976f99793 /src
parent8fda98c4f1dba2488b9e3ef3e820585f48a8a2f9 (diff)
nir/opcodes: Fix constant-folding of bitfield_insert
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104119 CC: <[email protected]> CC: Samuel Pitoiset <[email protected]> Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_opcodes.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index ac7333fe781..278562b2bd1 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -724,12 +724,12 @@ opcode("bitfield_insert", 0, tuint32, [0, 0, 0, 0],
unsigned base = src0, insert = src1;
int offset = src2, bits = src3;
if (bits == 0) {
- dst = 0;
+ dst = base;
} else if (offset < 0 || bits < 0 || bits + offset > 32) {
dst = 0;
} else {
unsigned mask = ((1ull << bits) - 1) << offset;
- dst = (base & ~mask) | ((insert << bits) & mask);
+ dst = (base & ~mask) | ((insert << offset) & mask);
}
""")