Mesa (main): nir: fix signed overflow for iadd constant folding

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 9 11:39:13 UTC 2021


Module: Mesa
Branch: main
Commit: e008eb12247ee2ad7410b0073b5f144a47767ec4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e008eb12247ee2ad7410b0073b5f144a47767ec4

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Thu Jul 29 11:12:29 2021 +0100

nir: fix signed overflow for iadd constant folding

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12039>

---

 src/compiler/nir/nir_opcodes.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index e37419c9b8c..2897a68f826 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -626,7 +626,7 @@ if (nir_is_rounding_mode_rtz(execution_mode, bit_size)) {
    dst = src0 + src1;
 }
 """)
-binop("iadd", tint, _2src_commutative + associative, "src0 + src1")
+binop("iadd", tint, _2src_commutative + associative, "(uint64_t)src0 + (uint64_t)src1")
 binop("iadd_sat", tint, _2src_commutative, """
       src1 > 0 ?
          (src0 + src1 < src0 ? (1ull << (bit_size - 1)) - 1 : src0 + src1) :



More information about the mesa-commit mailing list