mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 16:38:09 +02:00
nir: fix left shift of negative value in ibfe constant folding
Fixes "left shift of negative value -128" with parallel_rdp/00f93a9497dfbb3b and UBSan. Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35255>
This commit is contained in:
parent
78aae4b1ba
commit
397920c16e
1 changed files with 3 additions and 3 deletions
|
|
@ -1108,15 +1108,15 @@ if (bits == 0) {
|
|||
""")
|
||||
opcode("ibfe", 0, tint32,
|
||||
[0, 0, 0], [tint32, tuint32, tuint32], False, "", """
|
||||
int base = src0;
|
||||
uint32_t base = src0;
|
||||
unsigned offset = src1 & 0x1F;
|
||||
unsigned bits = src2 & 0x1F;
|
||||
if (bits == 0) {
|
||||
dst = 0;
|
||||
} else if (offset + bits < 32) {
|
||||
dst = (base << (32 - bits - offset)) >> (32 - bits);
|
||||
dst = util_mask_sign_extend(base >> offset, bits);
|
||||
} else {
|
||||
dst = base >> offset;
|
||||
dst = util_mask_sign_extend(base >> offset, 32 - offset);
|
||||
}
|
||||
""")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue