public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-837] middle-end/100582 - fix array_at_struct_end_p for vector indexing Date: Mon, 17 May 2021 13:27:49 +0000 (GMT) [thread overview] Message-ID: <20210517132749.26321385780B@sourceware.org> (raw) https://gcc.gnu.org/g:e0a5daf81f2c79a0275eccd7c1a25349990a7a4d commit r12-837-ge0a5daf81f2c79a0275eccd7c1a25349990a7a4d Author: Richard Biener <rguenther@suse.de> Date: Mon May 17 13:56:14 2021 +0200 middle-end/100582 - fix array_at_struct_end_p for vector indexing Vector indexing leaves us with ARRAY_REFs of VIEW_CONVERT_EXPRs, sth which array_at_struct_end_p considers a array-at-struct-end even when there's an underlying decl visible. The following fixes the latter. 2021-05-17 Richard Biener <rguenther@suse.de> PR middle-end/100582 * tree.c (array_at_struct_end_p): Get to the base of the reference before looking for the underlying decl. * gcc.target/i386/pr100582.c: New testcase. Diff: --- gcc/testsuite/gcc.target/i386/pr100582.c | 16 ++++++++++++++++ gcc/tree.c | 8 +++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gcc/testsuite/gcc.target/i386/pr100582.c b/gcc/testsuite/gcc.target/i386/pr100582.c new file mode 100644 index 00000000000..9520fe7a197 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr100582.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -mavx2" } */ + +typedef unsigned char v32qi __attribute__((vector_size(32))); + +v32qi +f2 (v32qi x, v32qi a, v32qi b) +{ + v32qi e; + for (int i = 0; i != 32; i++) + e[i] = x[i] ? a[i] : b[i]; + + return e; +} + +/* { dg-final { scan-assembler-times "pblendvb" 1 } } */ diff --git a/gcc/tree.c b/gcc/tree.c index 01eda553a65..8afba598eb5 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -12550,13 +12550,11 @@ array_at_struct_end_p (tree ref) || ! TYPE_MAX_VALUE (TYPE_DOMAIN (atype))) return true; - if (TREE_CODE (ref) == MEM_REF - && TREE_CODE (TREE_OPERAND (ref, 0)) == ADDR_EXPR) - ref = TREE_OPERAND (TREE_OPERAND (ref, 0), 0); - /* If the reference is based on a declared entity, the size of the array is constrained by its given domain. (Do not trust commons PR/69368). */ - if (DECL_P (ref) + ref = get_base_address (ref); + if (ref + && DECL_P (ref) && !(flag_unconstrained_commons && VAR_P (ref) && DECL_COMMON (ref)) && DECL_SIZE_UNIT (ref)
reply other threads:[~2021-05-17 13:27 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210517132749.26321385780B@sourceware.org \ --to=rguenth@gcc.gnu.org \ --cc=gcc-cvs@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).