aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2019-04-30 08:00:32 -0700
committerIan Romanick <[email protected]>2019-05-01 09:07:47 -0700
commit85e6865ff62390c632909a07a46deab54c742963 (patch)
tree40d1b6ebcaacde5a6b7424fcd445fe9c47119104 /src/compiler
parent70da00ffd65e56c8c8cc6ecfcec462fb52ee5102 (diff)
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: 272e927d0e9 ("nir/spirv: initial handling of OpenCL.std extension opcodes") Reviewed-by: Karol Herbst <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_opcodes.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index d35d820aa5b..246d3d40381 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -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)