public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/106475] Loop vectorizer prevents vectorization
Date: Fri, 29 Jul 2022 12:36:31 +0000	[thread overview]
Message-ID: <bug-106475-4-J5drNzvhjr@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106475-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The loop seems to be vectorized just fine?  The issue is just that we need a
runtime alias check because of the variable stride and the fact that we need a
VF of two to fill up to 16 byte vectors:

.L5:
        movq    (%rcx), %xmm1
        movq    (%rdx), %xmm0
        addl    $1, %esi
        movhps  (%rcx,%r10), %xmm1
        movhps  (%rdx,%r9), %xmm0
        addq    %r14, %rcx
        addq    %r13, %rdx
        paddb   %xmm1, %xmm0
        paddb   %xmm2, %xmm0
        movq    %xmm0, (%rax)
        movhps  %xmm0, (%rax,%rdi)
        addq    %r12, %rax
        cmpl    %esi, %r15d
        jne     .L5
        movl    %ebp, %eax
        andl    $-2, %eax
        andl    $1, %ebp
        je      .L1
.L4:
        imulq   %rax, %r10
        imulq   %rax, %r9
        imulq   %rdi, %rax
        movq    (%rbx,%r10), %xmm0
        movq    (%r8,%r9), %xmm1
        paddb   %xmm1, %xmm0
        movq    .LC1(%rip), %xmm1
        paddb   %xmm1, %xmm0
        movq    %xmm0, (%r11,%rax)

yes, the BB vectorization result is smaller but only uses half of a vector:

.L3:
        movq    (%r8), %xmm0
        movq    (%rdx), %xmm1
        addl    $1, %ecx
        addq    %rdi, %rdx
        addq    %rsi, %r8
        paddb   %xmm1, %xmm0
        paddb   %xmm2, %xmm0
        movq    %xmm0, (%rax)
        addq    %r10, %rax
        cmpl    %ecx, %r11d
        jne     .L3

  reply	other threads:[~2022-07-29 12:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29 11:43 [Bug tree-optimization/106475] New: " christophm30 at gmail dot com
2022-07-29 12:36 ` rguenth at gcc dot gnu.org [this message]
2022-07-29 13:38 ` [Bug tree-optimization/106475] " christophm30 at gmail dot com
2022-07-29 13:50 ` christophm30 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-106475-4-J5drNzvhjr@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).