public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: i.nixman@autistici.org
To: Hongtao Liu <crazylht@gmail.com>, gcc-help@gcc.gnu.org
Subject: Re: simd, redundant pcmpeqb and pxor
Date: Mon, 07 Nov 2022 06:26:57 +0000	[thread overview]
Message-ID: <71218c0c63bfa161f9f828cbf312debe@autistici.org> (raw)
In-Reply-To: <CAMZc-bx_f+mSmcvT1zc0kEEYngD26ed+USF9=WX838Fz=76TBQ@mail.gmail.com>

On 2022-11-07 03:32, Hongtao Liu wrote:
> On Sun, Nov 6, 2022 at 6:54 PM i.nixman--- via Gcc-help
> <gcc-help@gcc.gnu.org> wrote:
>> 
>> 
>> Hello,
>> 
>> look at this example(https://godbolt.org/z/TnGMsfMs6):
>> ```
>> auto foo(const char *p) {
>>      const auto substr = _mm_loadu_si128((const __m128i *)p);
>>      return _mm_cmplt_epi8(substr, _mm_set1_epi8('0'));
>> }
>> ```
>> and to the generated asm:
>> ```
>> 1: foo(char const*):
>> 2:    movdqu  xmm0, XMMWORD PTR [rdi]
>> 3:    pxor    xmm1, xmm1
>> 4:    pcmpgtb xmm0, XMMWORD PTR .LC0[rip]
>> 5:    pcmpeqb xmm0, xmm1
>> 6:    ret
>> ```
>> look at line 5.
>> is there any reason for `pcmpeqb` instruction?

hi,

> Looks like a mis optimization from
> 
> _4 = VIEW_CONVERT_EXPR<__v16qs>(_7);
> _3 = _4 <= { 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 
> 47, 47 };
> _5 = VIEW_CONVERT_EXPR<vector(16) signed char>(_3);  --- this?
> 
> Could you open a bugzilla for it
> https://gcc.gnu.org/bugzilla/

sure, but for which component?



>> 
>> just for info, clang's output(https://godbolt.org/z/MPnvEMdhr):
>> ```
>> 1: foo(char const*):
>> 2:    movdqu  xmm1, xmmword ptr [rdi]
>> 3:    movdqa  xmm0, xmmword ptr [rip + .LCPI0_0]
>> 4:    pcmpgtb xmm0, xmm1
>> 5:    ret
>> ```
>> 
>> 
>> best!

  reply	other threads:[~2022-11-07  6:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-06 10:53 i.nixman
2022-11-07  3:32 ` Hongtao Liu
2022-11-07  6:26   ` i.nixman [this message]
2022-11-07  6:32     ` Hongtao Liu
2022-11-07  6:40       ` i.nixman

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=71218c0c63bfa161f9f828cbf312debe@autistici.org \
    --to=i.nixman@autistici.org \
    --cc=crazylht@gmail.com \
    --cc=gcc-help@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).