public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/redhat/heads/gcc-8-branch)] lto/96591 - walk VECTOR_CST elements in walk_tree Date: Fri, 14 May 2021 14:54:40 +0000 (GMT) [thread overview] Message-ID: <20210514145440.C0669394BE03@sourceware.org> (raw) https://gcc.gnu.org/g:8e7e5d6958b84d8cf19db11fae125579350f70e1 commit 8e7e5d6958b84d8cf19db11fae125579350f70e1 Author: Richard Biener <rguenther@suse.de> Date: Mon Feb 8 09:52:56 2021 +0100 lto/96591 - walk VECTOR_CST elements in walk_tree This implements walking of VECTOR_CST elements in walk_tree, mimicing the walk of COMPLEX_CST elements. Without this free-lang-data fails to see some types in case they are only refered to via tree constants used only as VECTOR_CST elements. 2021-02-08 Richard Biener <rguenther@suse.de> PR lto/96591 * tree.c (walk_tree_1): Walk VECTOR_CST elements. * g++.dg/lto/pr96591_0.C: New testcase. (cherry picked from commit d4536e431316b4568e236afd7a6017e5efd1b0a1) Diff: --- gcc/testsuite/g++.dg/lto/pr96591_0.C | 45 ++++++++++++++++++++++++++++++++++++ gcc/tree.c | 13 ++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/g++.dg/lto/pr96591_0.C b/gcc/testsuite/g++.dg/lto/pr96591_0.C new file mode 100644 index 00000000000..ae2dc98efc4 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr96591_0.C @@ -0,0 +1,45 @@ +// { dg-lto-do assemble } +// { dg-lto-options { { -O -flto } } } + +template <typename scalar_t, unsigned length> +struct builtin_simd +{ + using type [[gnu::vector_size(sizeof(scalar_t) * length)]] = scalar_t; +}; + +struct simd_traits +{ + using scalar_type = int; + + template <typename new_scalar_type> + using rebind = typename builtin_simd<new_scalar_type, 1>::type; +}; + +template <typename simd_t> +constexpr simd_t fill(typename simd_traits::scalar_type const scalar) +{ + return simd_t{scalar}; +} + +class Test +{ + using score_type = typename builtin_simd<int, 1>::type; + score_type data[1]{fill<score_type>(8)}; +}; + +struct TestFactoryBase +{ + virtual Test *CreateTest() = 0; +}; + +template <class TestClass> +struct TestFactoryImpl : public TestFactoryBase +{ + Test *CreateTest() override { return new TestClass; } +}; + +void MakeAndRegisterTestInfo(TestFactoryBase *factory); + +int main() { + MakeAndRegisterTestInfo(new TestFactoryImpl<Test>); +} diff --git a/gcc/tree.c b/gcc/tree.c index 3774ff4bf4b..cba0222675c 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -11434,7 +11434,6 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, case INTEGER_CST: case REAL_CST: case FIXED_CST: - case VECTOR_CST: case STRING_CST: case BLOCK: case PLACEHOLDER_EXPR: @@ -11465,6 +11464,18 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, WALK_SUBTREE_TAIL (TREE_VEC_ELT (*tp, 0)); } + case VECTOR_CST: + { + unsigned len = vector_cst_encoded_nelts (*tp); + if (len == 0) + break; + /* Walk all elements but the first. */ + while (--len) + WALK_SUBTREE (VECTOR_CST_ENCODED_ELT (*tp, len)); + /* Now walk the first one as a tail call. */ + WALK_SUBTREE_TAIL (VECTOR_CST_ENCODED_ELT (*tp, 0)); + } + case COMPLEX_CST: WALK_SUBTREE (TREE_REALPART (*tp)); WALK_SUBTREE_TAIL (TREE_IMAGPART (*tp));
reply other threads:[~2021-05-14 14:54 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=20210514145440.C0669394BE03@sourceware.org \ --to=jakub@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).