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/102591] Failure to optimize search for value in vector-sized area to use SIMD
Date: Tue, 05 Oct 2021 10:19:17 +0000	[thread overview]
Message-ID: <bug-102591-4-hb8Mk69imA@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102591-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
          Component|target                      |tree-optimization
             Blocks|                            |53947

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Gabriel Ravier from comment #2)
> memcpy can fail on unaligned memory ??? I used it specifically to avoid this
> problem !
> 
> (also, LLVM's code, I am pretty sure, does not have any issue with
> alignment, as it uses either AVX instructions which care not for it, or
> specifically does a movdqu (i.e. unaligned load) of the memory)

Ah, sorry - I was reading the loop as

    for (int at = 0; at < 16; at++)
        if (tpl[at] == 0)
          {
            found = 1;
            break;
          }

thus as if the suggested transform would eventually access storage that is
not accessed originally...

Btw, we vectorize

bool match8(char *tpl) 
{
    char found = 0;
    for (int at = 0; at < 16; at++)
        if (tpl[at] == 0)
            found = 1;
    return found;
}

but use

  vector(16) char vect_found_4.8;

  vect__3.7_29 = MEM <vector(16) char> [(char *)tpl_10(D)];
  _32 = vect__3.7_29 != { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  vect_found_4.8_33 = VEC_COND_EXPR <_32, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }>;
  _35 = .REDUC_MAX (vect_found_4.8_33);
  _8 = (bool) _35;
  return _8;

where we fail to apply "magic" to the .REDUC_MAX as we know the values
are all 0 or 1.

The conditional reduction support doesn't support producing 'int' from
char compares and we fail to narrow the reduction vector.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

      parent reply	other threads:[~2021-10-05 10:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04 12:12 [Bug target/102591] New: " gabravier at gmail dot com
2021-10-05  6:44 ` [Bug target/102591] " rguenth at gcc dot gnu.org
2021-10-05  9:46 ` gabravier at gmail dot com
2021-10-05 10:19 ` rguenth at gcc dot gnu.org [this message]

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-102591-4-hb8Mk69imA@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).