public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "denis.campredon at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/97961] New: unnecessary moves with __builtin_{add,sub}_overflow_p and __int128 Date: Mon, 23 Nov 2020 17:58:46 +0000 [thread overview] Message-ID: <bug-97961-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97961 Bug ID: 97961 Summary: unnecessary moves with __builtin_{add,sub}_overflow_p and __int128 Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: denis.campredon at gmail dot com Target Milestone: --- In #97950 Jackub told me to open a new bug for that. The snippet bellow has the following problems - f1 and f2 generate 4 unnecessary moves mov r9, rdi mov r8, rsi mov rsi, r9 mov rdi, r8 - f4 has "only" 2 unnecessary moves mov r9, rdi mov rdi, rsi - f3 should be identical to f4 except for the flag checking. ------------ bool f1(unsigned __int128 a,unsigned __int128 b) { return __builtin_add_overflow_p(a, b, (unsigned __int128)0); } bool f2(__int128 a,__int128 b) { return __builtin_add_overflow_p(a, b, (__int128)0); } bool f3(unsigned __int128 a,unsigned __int128 b) { return __builtin_sub_overflow_p(a, b, (unsigned __int128)0); } bool f4(__int128 a,__int128 b) { return __builtin_sub_overflow_p(a, b, (__int128)0); } ------------ asm generated ------------ f1(unsigned __int128, unsigned __int128): mov r9, rdi mov r8, rsi mov rsi, r9 mov rdi, r8 add rsi, rdx adc rdi, rcx setc al ret f2(__int128, __int128): mov r9, rdi mov r8, rsi mov rsi, r9 mov rdi, r8 add rsi, rdx adc rdi, rcx seto al ret f3(unsigned __int128, unsigned __int128): mov r9, rdi mov r8, rsi mov rdi, r8 mov rax, r9 mov r8, rdx sub rax, r8 mov rdx, rdi sbb rdx, rcx cmp r9, rax mov rcx, rdi sbb rcx, rdx setc al ret f4(__int128, __int128): mov r9, rdi mov rdi, rsi cmp r9, rdx sbb rdi, rcx seto al ret -------------------
next reply other threads:[~2020-11-23 17:58 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-23 17:58 denis.campredon at gmail dot com [this message] 2022-11-08 0:14 ` [Bug rtl-optimization/97961] " pinskia at gcc dot gnu.org 2023-01-19 23:23 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-97961-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).