From: Uros Bizjak <ubizjak@gmail.com>
To: Roger Sayle <roger@nextmovesoftware.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [x86 PATCH] Support logical shifts by (some) integer constants in TImode STV.
Date: Sun, 31 Jul 2022 19:22:31 +0200 [thread overview]
Message-ID: <CAFULd4Z98PCfCt5a3skRGDVLcNWFvZ5RRiLFBP2Lonw4WUjmOA@mail.gmail.com> (raw)
In-Reply-To: <032901d8a2cf$fc07cfd0$f4176f70$@nextmovesoftware.com>
On Fri, Jul 29, 2022 at 12:18 AM Roger Sayle <roger@nextmovesoftware.com> wrote:
>
>
> This patch improves TImode STV by adding support for logical shifts by
> integer constants that are multiples of 8. For the test case:
>
> __int128 a, b;
> void foo() { a = b << 16; }
>
> on x86_64, gcc -O2 currently generates:
>
> movq b(%rip), %rax
> movq b+8(%rip), %rdx
> shldq $16, %rax, %rdx
> salq $16, %rax
> movq %rax, a(%rip)
> movq %rdx, a+8(%rip)
> ret
>
> with this patch we now generate:
>
> movdqa b(%rip), %xmm0
> pslldq $2, %xmm0
> movaps %xmm0, a(%rip)
> ret
>
> This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
> and make -k check. both with and without --target_board=unix{-m32},
> with no new failures. Ok for mainline?
>
>
> 2022-07-28 Roger Sayle <roger@nextmovesoftware.com>
>
> gcc/ChangeLog
> * config/i386/i386-features.cc (compute_convert_gain): Add gain
> for converting suitable TImode shift to a V1TImode shift.
> (timode_scalar_chain::convert_insn): Add support for converting
> suitable ASHIFT and LSHIFTRT.
> (timode_scalar_to_vector_candidate_p): Consider logical shifts
> by integer constants that are multiples of 8 to be candidates.
>
> gcc/testsuite/ChangeLog
> * gcc.target/i386/sse4_1-stv-7.c: New test case.
+ case ASHIFT:
+ case LSHIFTRT:
+ /* For logical shifts by constant multiples of 8. */
+ igain = optimize_insn_for_size_p () ? COSTS_N_BYTES (4)
+ : COSTS_N_INSNS (1);
Isn't the conversion an universal win for -O2 as well as for -Os? The
conversion to/from XMM register is already accounted for, so for -Os
substituting shldq/salq with pslldq should always be a win. I'd expect
the cost calculation to be similar to the
general_scalar_chain::compute_convert_gain cost calculation with m =
2.
Uros.
next prev parent reply other threads:[~2022-07-31 17:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-28 22:18 Roger Sayle
2022-07-31 17:22 ` Uros Bizjak [this message]
2022-08-02 17:02 ` Roger Sayle
2022-08-02 17:22 ` Uros Bizjak
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=CAFULd4Z98PCfCt5a3skRGDVLcNWFvZ5RRiLFBP2Lonw4WUjmOA@mail.gmail.com \
--to=ubizjak@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=roger@nextmovesoftware.com \
/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).