public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "linkw at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104595] New: unvectorized loop due to bool condition loaded from memory Date: Fri, 18 Feb 2022 10:05:59 +0000 [thread overview] Message-ID: <bug-104595-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104595 Bug ID: 104595 Summary: unvectorized loop due to bool condition loaded from memory Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: linkw at gcc dot gnu.org Target Milestone: --- For the case: #include "stdbool.h" #define N 256 typedef char T; extern T a[N]; extern T b[N]; extern T c[N]; extern bool pb[N]; extern char pc[N]; void predicate_by_bool() { for (int i = 0; i < N; i++) c[i] = pb[i] ? a[i] : b[i]; } void predicate_by_char() { for (int i = 0; i < N; i++) c[i] = pc[i] ? a[i] : b[i]; } Simply compiled with -Ofast -mcpu=power10, vectorizer can vectorize the 2nd function predicate_by_char but can't vectorize the first. It seems currently GCC just supports very limited case with bool types such as some patterns in vect_recog_bool_pattern. I guess here the size of bool seems to be a problem, for the size of bool, C says "An object declared as type _Bool is large enough to store the values 0 and 1.", C++ says "The value of sizeof(bool) is implementation defined and might differ from 1.". But the "implementation defined" looks to be compiler defined? then compiler should be aware of it when compiling. If so, we can use the equivalent size type for the load instead and make it compare with zero to get the predicate just like the char variant, I think the expectation to see both these loops vectorized is reasonable then?
next reply other threads:[~2022-02-18 10:06 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-18 10:05 linkw at gcc dot gnu.org [this message] 2022-02-18 10:27 ` [Bug tree-optimization/104595] " rguenth at gcc dot gnu.org 2022-02-18 16:26 ` segher at gcc dot gnu.org 2022-02-20 3:52 ` pinskia at gcc dot gnu.org 2022-02-20 3:58 ` pinskia at gcc dot gnu.org 2022-02-21 7:54 ` rguenth at gcc dot gnu.org 2022-02-21 10:01 ` rguenth at gcc dot gnu.org 2022-02-21 13:26 ` rguenth at gcc dot gnu.org 2022-02-21 13:45 ` rguenth at gcc dot gnu.org 2022-02-23 7:18 ` linkw at gcc dot gnu.org 2022-02-23 7:41 ` rguenther at suse dot de 2022-02-23 8:55 ` linkw at gcc dot gnu.org 2022-05-05 8:37 ` cvs-commit at gcc dot gnu.org 2022-05-05 8:39 ` rguenth at gcc dot gnu.org
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-104595-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: linkBe 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).