mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
nir: Saturating integer arithmetic is not associative
In 8-bits,
iadd_sat(iadd_sat(0x7f, 0x7f), -1) =
iadd_sat(0x7f, -1) =
0x7e
but,
iadd_sat(0x7f, iadd_sat(0x7f, -1)) =
iadd_sat(0x7f, 0x7e) =
0x7f
Fixes: 272e927d0e ("nir/spirv: initial handling of OpenCL.std extension opcodes")
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
parent
70da00ffd6
commit
85e6865ff6
1 changed files with 1 additions and 1 deletions
|
|
@ -482,7 +482,7 @@ def binop_reduce(name, output_size, output_type, src_type, prereduce_expr,
|
|||
|
||||
binop("fadd", tfloat, commutative + associative, "src0 + src1")
|
||||
binop("iadd", tint, commutative + associative, "src0 + src1")
|
||||
binop("iadd_sat", tint, commutative + associative, """
|
||||
binop("iadd_sat", tint, commutative, """
|
||||
src1 > 0 ?
|
||||
(src0 + src1 < src0 ? (1ull << (bit_size - 1)) - 1 : src0 + src1) :
|
||||
(src0 < src0 + src1 ? (1ull << (bit_size - 1)) : src0 + src1)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue