From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 891283858C98; Mon, 26 Feb 2024 18:50:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 891283858C98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708973457; bh=V7FYNG0u4fpqBWjlKXJjEaEsBBF7F+pgJUWJXgL4LnI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AB7sTxwIXmkxloMxwo/Hxmdcs+EqrHrqSfgXkWUJU7bpDFMbo4wRZmX1aewpjreCu SxsGAKdOpeOZV468z7EB6klxGh5+4fi10/Tr8zWSQavm0jQHt+PL6DAzer2t4kXzUP E/VqSGsGJB6gsRaWWNg/8zsVNBAYXvNaX6v8evQQ= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114121] wrong code with _BitInt() arithmetics at -O2 Date: Mon, 26 Feb 2024 18:50:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114121 --- Comment #3 from Jakub Jelinek --- Indeed. And -O2 -fno-tree-vectorize works. I've changed it to unsigned a, b, c, d, e; unsigned _BitInt(256) f; __attribute__((noipa)) unsigned short bswap16 (int t) { return __builtin_bswap16 (t); } void foo (unsigned z, unsigned _BitInt(512) y, unsigned *r) { unsigned t =3D __builtin_sub_overflow_p (0, y << 509, f); z *=3D bswap16 (t); d =3D __builtin_sub_overflow_p (c, 3, (unsigned _BitInt(512)) 0); unsigned q =3D z + c + b; unsigned short n =3D q >> (8 + a); *r =3D b + e + n; } int main () { unsigned x; foo (8, 2, &x); if (x !=3D 8) __builtin_abort (); } and bswap16 is called with 1 with -O2 -fno-tree-vectorize and 0 with -O2, so the problem is either during the computation of y << 509 (but that is fairly simple thing out of bitintlower, set highest limb to the lowest limb << 61 = and clear all others), or during the sub overflow.=