From bb8de8c63362b7234db02482240d5600203225d9 Mon Sep 17 00:00:00 2001 From: Alexey Yerin Date: Fri, 2 Aug 2024 14:39:07 +0300 Subject: [PATCH] arm64/isel: Avoid signed overflow when handling immediates Clang incorrectly optimizes this negation with -O2 and causes QBE to emit 0 in place of INT64_MIN. --- arm64/isel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arm64/isel.c b/arm64/isel.c index 062beb3..9ce6adc 100644 --- a/arm64/isel.c +++ b/arm64/isel.c @@ -24,7 +24,7 @@ imm(Con *c, int k, int64_t *pn) i = Iplo12; if (n < 0) { i = Inlo12; - n = -n; + n = -(uint64_t)n; } *pn = n; if ((n & 0x000fff) == n) -- 2.11.4.GIT