From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BD4333858D28; Sun, 5 Dec 2021 15:41:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD4333858D28 From: "unlvsur at live dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103565] New: GCC emits more assembly than clang for carry flag Date: Sun, 05 Dec 2021 15:41:42 +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: 12.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 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Dec 2021 15:41:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103565 Bug ID: 103565 Summary: GCC emits more assembly than clang for carry flag Product: gcc Version: 12.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: --- I tried both examples. One emulation with the pattern. Another is with the = x86 intrinsic. GCC emits more instructions than clang. https://godbolt.org/z/d15WEY85T https://godbolt.org/z/cob36P8nz Also can GCC be able to understand the pattern of add_carry_pattern just li= ke it understands std::rotl?=20 https://github.com/gcc-mirror/gcc/blob/8d4ef2299cbf9517877dab60d48f34835758= a6ee/libstdc%2B%2B-v3/include/std/bit#L135 template inline constexpr bool add_carry_pattern(bool carry,T a,T b,T& out) noexcept { T temp{carry+a}; out=3Dtemp+b; return (out < b) | (temp < a); } So we do not need that intrinsic anymore and the whole thing can be optimiz= ed at SSA level, rather than RTL level??=