public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "moncef.mechri at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/110551] [11/12/13/14 Regression] an extra mov when doing 128bit multiply
Date: Sun, 29 Oct 2023 18:01:00 +0000	[thread overview]
Message-ID: <bug-110551-4-h16CPmJfvq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110551-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110551

--- Comment #6 from Moncef Mechri <moncef.mechri at gmail dot com> ---
I confirm the extra mov disappears thanks to Roger's patch.

However, the codegen still seems suboptimal to me when using -march=haswell or
newer, even with Roger's patch:

uint64_t mulx64(uint64_t x)
{
    __uint128_t r = (__uint128_t)x * 0x9E3779B97F4A7C15ull;
    return (uint64_t)r ^ (uint64_t)( r >> 64 );
}


With -O2:

mulx64(unsigned long):
        movabs  rax, -7046029254386353131
        mul     rdi
        xor     rax, rdx
        ret

With -O2 -march=haswell

mulx64(unsigned long):
        movabs  rdx, -7046029254386353131
        mulx    rdi, rsi, rdi
        mov     rax, rdi
        xor     rax, rsi
        ret

So it looks like there is still one extra mov, since I think the optimal
codegen using mulx should be:

mulx64(unsigned long):
        movabs  rdx, -7046029254386353131
        mulx    rax, rsi, rdi
        xor     rax, rsi
        ret

  parent reply	other threads:[~2023-10-29 18:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-04 17:26 [Bug rtl-optimization/110551] New: [11 / 12 / 13 /14 regression] Suboptimal codegen for 128 bits multiplication on x86_64 moncef.mechri at gmail dot com
2023-07-04 17:32 ` [Bug target/110551] [11/12/13/14 " pinskia at gcc dot gnu.org
2023-07-04 17:47 ` [Bug target/110551] [11/12/13/14 Regression] an extra mov when doing 128bit multiply pinskia at gcc dot gnu.org
2023-07-04 18:12 ` moncef.mechri at gmail dot com
2023-07-05  7:06 ` rguenth at gcc dot gnu.org
2023-10-18 19:11 ` roger at nextmovesoftware dot com
2023-10-27  9:05 ` cvs-commit at gcc dot gnu.org
2023-10-29 18:01 ` moncef.mechri at gmail dot com [this message]
2023-11-01 10:06 ` ubizjak at gmail dot com
2023-11-01 22:35 ` cvs-commit at gcc dot gnu.org
2023-11-06 19:24 ` moncef.mechri at gmail dot com
2023-11-12 15:48 ` [Bug target/110551] [11/12/13 " roger at nextmovesoftware dot com

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-110551-4-h16CPmJfvq@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: link
Be 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).