public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: i.nixman@autistici.org
To: gcc-help@gcc.gnu.org
Subject: simd, redundant pcmpeqb and pxor
Date: Sun, 06 Nov 2022 10:53:18 +0000	[thread overview]
Message-ID: <ed79f60952d043793bbb5ab667e06cbc@autistici.org> (raw)


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?

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-06 10:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-06 10:53 i.nixman [this message]
2022-11-07  3:32 ` Hongtao Liu
2022-11-07  6:26   ` i.nixman
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=ed79f60952d043793bbb5ab667e06cbc@autistici.org \
    --to=i.nixman@autistici.org \
    --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).