From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 294D23898505; Mon, 12 Apr 2021 11:23:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 294D23898505 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9341] lto/96591 - walk VECTOR_CST elements in walk_tree X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-9 X-Git-Oldrev: 969be2412231d3bdd73300ac32684d416345a029 X-Git-Newrev: c0ae84d67a61512ec36d5c82ae52090c4b6440d1 Message-Id: <20210412112338.294D23898505@sourceware.org> Date: Mon, 12 Apr 2021 11:23:38 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Apr 2021 11:23:38 -0000 https://gcc.gnu.org/g:c0ae84d67a61512ec36d5c82ae52090c4b6440d1 commit r9-9341-gc0ae84d67a61512ec36d5c82ae52090c4b6440d1 Author: Richard Biener 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 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 +struct builtin_simd +{ + using type [[gnu::vector_size(sizeof(scalar_t) * length)]] = scalar_t; +}; + +struct simd_traits +{ + using scalar_type = int; + + template + using rebind = typename builtin_simd::type; +}; + +template +constexpr simd_t fill(typename simd_traits::scalar_type const scalar) +{ + return simd_t{scalar}; +} + +class Test +{ + using score_type = typename builtin_simd::type; + score_type data[1]{fill(8)}; +}; + +struct TestFactoryBase +{ + virtual Test *CreateTest() = 0; +}; + +template +struct TestFactoryImpl : public TestFactoryBase +{ + Test *CreateTest() override { return new TestClass; } +}; + +void MakeAndRegisterTestInfo(TestFactoryBase *factory); + +int main() { + MakeAndRegisterTestInfo(new TestFactoryImpl); +} diff --git a/gcc/tree.c b/gcc/tree.c index d747a0bf685..be311754393 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -12189,7 +12189,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: @@ -12220,6 +12219,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));