From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 2B0A93858D37; Sat, 10 Feb 2024 11:53:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B0A93858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707565991; bh=gqhjz0bNYGTtlPPf21AcnmqLV5jNkNijvGFJfmml4Ck=; h=From:To:Subject:Date:From; b=t4mqQBJJnhDMAnedvAeJnwuo+6QasHiU4+h7vNc+8lsuCZe9BOB5TZjWQ8+JnWbgq 4K/4pTtw5m+zCPZXjB4FZ8nf3hvyRgLZOXFZH1PoeUyNEe57+kvQnkdXIbGxxAsJO5 X3fHn05j0CWmNtoqGVePbjlVpn0a34ctLRuDQwf0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8913] lower-bitint: Fix up .{ADD,SUB}_OVERFLOW lowering X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 1e87fcf200897b64ca428c8ef80c3ad876828caf X-Git-Newrev: d10c0dce53b2f1435fb66a570f15310baef5172d Message-Id: <20240210115311.2B0A93858D37@sourceware.org> Date: Sat, 10 Feb 2024 11:53:11 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d10c0dce53b2f1435fb66a570f15310baef5172d commit r14-8913-gd10c0dce53b2f1435fb66a570f15310baef5172d Author: Jakub Jelinek Date: Sat Feb 10 12:52:23 2024 +0100 lower-bitint: Fix up .{ADD,SUB}_OVERFLOW lowering torture/bitint-37.c test FAILed on i686-linux e.g. on signed _BitInt(575) + unsigned _BitInt(575) -> signed _BitInt(575) __builtin_add_overflow. With 64-bit limbs, we use 4 .UADDC calls in the IL, 2 in a loop (which handles the first 8 limbs), then one partial limb (we use 63 bits from that) and finally last_ovf case due to the mixing of signed vs. unsigned. But with 32-bit limbs, we use 5 .UADDC calls in the IL, 2 in a loop (which handles the first 16 limbs), then one full limb above that, one partial (31 bits) and finally last_ovf case, and for the last_ovf case the code computed incorrect idx and so partly did the wrong thing, e.g. overwrote the result from the previous .UADDC. Fixed thusly. 2024-02-10 Jakub Jelinek * gimple-lower-bitint.cc (itint_large_huge::lower_addsub_overflow): Fix computation of idx for i == 4 of bitint_prec_huge. Diff: --- gcc/gimple-lower-bitint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc index e29d83193265..caa33e0aacf1 100644 --- a/gcc/gimple-lower-bitint.cc +++ b/gcc/gimple-lower-bitint.cc @@ -4031,7 +4031,7 @@ bitint_large_huge::lower_addsub_overflow (tree obj, gimple *stmt) if (kind != bitint_prec_huge) idx = size_int (i); else if (i >= 2) - idx = size_int (fin + (i > 2)); + idx = size_int (fin + i - 2); if (!last_ovf || i < cnt - 1) { if (type0 != TREE_TYPE (arg0))