public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "crazylht at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/104946] New: [12 regression] Suboptimal gimple foding for blendvpd under sse4.1
Date: Wed, 16 Mar 2022 05:54:48 +0000	[thread overview]
Message-ID: <bug-104946-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 104946
           Summary: [12 regression] Suboptimal gimple foding for blendvpd
                    under sse4.1
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

When working on PR104666, i found

cat test.c

typedef double __m128d __attribute__((__vector_size__(16), __may_alias__));
__m128d sse4_1_blendvpd (__m128d a, __m128d b, __m128d c)
__attribute__((__target__("sse4.1")));

__m128d
generic_blendvpd (__m128d a, __m128d b, __m128d c)
{
  return __builtin_ia32_blendvpd (a, b, c);
}

gcc -O2 -msse4.1 -mno-sse4.2

generic_blendvpd:
        movq    rax, xmm2
        movapd  xmm3, xmm0
        test    rax, rax
        jns     .L3
        movapd  xmm0, xmm1
.L3:
        pextrq  rax, xmm2, 1
        unpckhpd        xmm3, xmm3
        test    rax, rax
        jns     .L5
        unpckhpd        xmm1, xmm1
        movapd  xmm3, xmm1
.L5:
        unpcklpd        xmm0, xmm3
        ret

It's because it pcmpgtq is under sse4.2 w/o which vec_cmpv2di will be lower to
scalar operations and not combined back.

w/ sse4.2 gcc can generate optimal code.

generic_blendvpd:
        movapd  xmm3, xmm0
        movdqa  xmm0, xmm2
        blendvpd        xmm3, xmm1, xmm0
        movapd  xmm0, xmm3
        ret

             reply	other threads:[~2022-03-16  5:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16  5:54 crazylht at gmail dot com [this message]
2022-03-16  5:58 ` [Bug target/104946] " crazylht at gmail dot com
2022-03-16  7:53 ` rguenth at gcc dot gnu.org
2022-03-16  8:57 ` cvs-commit at gcc dot gnu.org
2022-03-16  9:00 ` crazylht at gmail 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-104946-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: 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).