From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4FA18385842B; Sat, 24 Jun 2023 13:14:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4FA18385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687612475; bh=7jhg3w+b9I6x+ywotEfjx5HrcrmG8B24DCoQ1FDS9Kw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FmRTouCyPASKywy95C+soUxCrge8y3ydZU5S3qarO4gKAeNLj/w7KnO4DT/dHocI3 2XH03mpvL1p11u+TQitK68gP9k+WyuPFcefuI8w91CwOzU1HDRJwhQ3qr1UphZQmge 2hviLZK9BCL87aeP03zaZMuj6K6iGEJHa40iWXpg= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/79173] add-with-carry and subtract-with-borrow support (x86_64 and others) Date: Sat, 24 Jun 2023 13:14:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 7.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub 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=3D79173 --- Comment #31 from Jakub Jelinek --- (In reply to Vincent Lef=C3=A8vre from comment #30) > (In reply to Jakub Jelinek from comment #29) > > (In reply to Vincent Lef=C3=A8vre from comment #28) > > > What do you mean by "the first additions will be less optimized"? (If= you > > > don't know anything about the initial carryin and the arguments, you = can't > > > optimize at all, AFAIK.) > >=20 > > I mean that if the compiler can't see it is in [0, 1], it will need to = use 2 > > additions and or the 2 carry bits together. But, because the ored carry > > bits are in [0, 1] range, all the higher limbs could be done using addc. >=20 > If the compiler can't see that carryin is in [0, 1], then it must not "or" > the carry bits; it needs to add them, as carryout may be 2. That is not how the clang builtin works, which is why I've implemented the | and documented it that way, as it is a compatibility builtin.=