From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A8BFA3858C2C; Thu, 23 Dec 2021 00:46:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8BFA3858C2C From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/43883] missed optimization of constant __int128_t modulus Date: Thu, 23 Dec 2021 00:46:56 +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: 4.5.0 X-Bugzilla-Keywords: missed-optimization, ra X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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 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: Thu, 23 Dec 2021 00:46:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D43883 --- Comment #7 from Andrew Pinski --- 4.7 produces: shr rsi, 63 mov rax, rdi xor edi, edi add rax, rsi xor r10d, r10d mov r9, rax mov rdx, r10 and r9d, 1 mov rax, r9 sub rax, rsi sbb rdx, rdi ret 4.9: mov rcx, rsi sar rcx, 63 xor rdi, rcx mov rdx, rcx mov rax, rdi sub rax, rcx and eax, 1 xor rax, rcx sub rax, rcx sbb rdx, rcx ret 7.1.0-7.3.0, 8.1.0-8.2.0 decides not to inline it: sub rsp, 8 .cfi_def_cfa_offset 16 mov edx, 2 xor ecx, ecx call __modti3 add rsp, 8 .cfi_def_cfa_offset 8 ret And then we are back to the 4.9 code gen for 7.4, 8.3 and 9.x 10.x produces: mov r10, rsi mov r8, rdi sar r10, 63 xor r8, r10 mov rdx, r10 mov rax, r8 sub rax, r10 and eax, 1 xor rax, r10 sub rax, r10 sbb rdx, r10 ret GCC 11 and trunk is back to the 4.9 code gen=