From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CE2BB3858D33; Mon, 28 Aug 2023 06:47:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE2BB3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693205247; bh=kVL6uI/BRDhrLXDHFMcAvhBPJTC/q15NXUoGmaMjEfk=; h=From:To:Subject:Date:From; b=Ks6TlkQ/gEAi4vYkTeQ206eFbmqYvclTHTVEXEqjibYBFNHM+iPgQhgw0uTqJBPbk X25sh06OymUdHfEkb9vbgHjdWZKcxwmItG2OjCrB8BZn4vX93EzLelCbdbZrzr3f3i kBzjCfh4rU1NIZKTpMvBMbq2fbvLlDIP8QKmtkrw= From: "unlvsur at live dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111209] New: GCC fails to understand adc pattern Date: Mon, 28 Aug 2023 06:47:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: unlvsur at live dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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=3D111209 Bug ID: 111209 Summary: GCC fails to understand adc pattern Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: unlvsur at live dot com Target Milestone: --- Created attachment 55805 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55805&action=3Dedit bug example template inline constexpr T addc(T a,T b,bool carryin,bool& carryout) noexcept { T s; auto c1 =3D __builtin_add_overflow(a, b, __builtin_addressof(s)); auto c2 =3D __builtin_add_overflow(s, carryin, __builtin_addressof(= s)); carryout =3D c1 | c2; return s; } void test_addc(unsigned long long* a,unsigned long long* b,unsigned long lo= ng* r) { bool carry{}; r[0]=3Daddc(a[0],b[0],carry,carry); r[1]=3Daddc(a[1],b[1],carry,carry); } I copied the example from gcc documentation https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html But gcc seems to fail to understand the pattern correctly even with what the document describes. gcc: https://godbolt.org/z/Whaaahn41 clang: https://godbolt.org/z/Ma6rvaYd6 Looks like a bug here.=