From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B1A4A3858406; Mon, 21 Feb 2022 06:29:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1A4A3858406 From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/51954] __int128_t (and long long on x86) negation can be optimized Date: Mon, 21 Feb 2022 06:29:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.7.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: crazylht at gmail dot com 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 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: Mon, 21 Feb 2022 06:29:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D51954 --- Comment #4 from Hongtao.liu --- (In reply to Andrew Pinski from comment #2) > We get this now: >=20 > movq %rdi, %rax > movq %rsi, %rdx > negq %rax > adcq $0, %rdx > negq %rdx >=20 > ICC produces: > xorl %edx, %edx #3.10 > xorl %eax, %eax #3.10 > subq %rdi, %rax #3.10 > sbbq %rsi, %rdx #3.10 > ret #3.10 >=20 > Which seems even better. >=20 > LLVM does produce: > movq %rdi, %rax > xorl %edx, %edx > negq %rax > sbbq %rsi, %rdx >=20 > Which basically combines the addcq and negq together and changes one mov > into an exor. Yes, neg rdx =3D (0 - rdx) =3D (0 - (rdx + CF)(last def)) =3D (sbb 0, rdx)=