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 <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
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)