From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id EF16B3851888; Wed, 23 Nov 2022 18:10:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF16B3851888 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669227011; bh=CNsVhWSHG4EUts2y+4yU7n5661+sD8cEHPNcJmEbkfI=; h=From:To:Subject:Date:From; b=HkKWvRUFaWM5ckAMK6f2zMU+qiYFX3nojgWbpaFVoWShs85AK02+t+LRwssuTTV5u lK0HifeZP27QjUHeRAwrMp1BdCobuRZznfQRAVfDBXwh9CIM4iMPAmoO1AsKHu38AG 1VoyJ4GG17bQeRRl7OAuCXlJsKzv/LyzbTyj0UNQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4268] c: Fix compile time hog in c_genericize [PR107127] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: c087fe834b19d6c281ce25f729d891bcd14ce404 X-Git-Newrev: 8a0fce6a51915c29584427fd376b40073c328090 Message-Id: <20221123181011.EF16B3851888@sourceware.org> Date: Wed, 23 Nov 2022 18:10:11 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8a0fce6a51915c29584427fd376b40073c328090 commit r13-4268-g8a0fce6a51915c29584427fd376b40073c328090 Author: Jakub Jelinek Date: Wed Nov 23 19:09:31 2022 +0100 c: Fix compile time hog in c_genericize [PR107127] The complex multiplications result in deeply nested set of many SAVE_EXPRs, which takes even on fast machines over 5 minutes to walk. This patch fixes that by using walk_tree_without_duplicates where it is instant. 2022-11-23 Andrew Pinski Jakub Jelinek PR c/107127 * c-gimplify.cc (c_genericize): Use walk_tree_without_duplicates instead of walk_tree for c_genericize_control_r. * gcc.dg/pr107127.c: New test. Diff: --- gcc/c-family/c-gimplify.cc | 4 ++-- gcc/testsuite/gcc.dg/pr107127.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gcc/c-family/c-gimplify.cc b/gcc/c-family/c-gimplify.cc index 039a4b93230..0034d41d33a 100644 --- a/gcc/c-family/c-gimplify.cc +++ b/gcc/c-family/c-gimplify.cc @@ -572,8 +572,8 @@ c_genericize (tree fndecl) bc_state_t save_state; push_cfun (DECL_STRUCT_FUNCTION (fndecl)); save_bc_state (&save_state); - walk_tree (&DECL_SAVED_TREE (fndecl), c_genericize_control_r, - NULL, NULL); + walk_tree_without_duplicates (&DECL_SAVED_TREE (fndecl), + c_genericize_control_r, NULL); restore_bc_state (&save_state); pop_cfun (); } diff --git a/gcc/testsuite/gcc.dg/pr107127.c b/gcc/testsuite/gcc.dg/pr107127.c new file mode 100644 index 00000000000..f7ae87db70e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr107127.c @@ -0,0 +1,12 @@ +/* PR c/107127 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int *v; + +_Complex double +foo (_Complex double a, double b, double c) +{ + return v[0] / ((((c * (0 - 0 / a + 699.0 + 7.05 - 286.0 - +-4.65 + 1.57 + 0) * 0.1 - 3.28 + 4.22 + 0.1)) * b + 5.06) + * 1.23 * 8.0 * 12.0 * 16.0 * 2.0 * 2.0 * 0.25 * 0.125 * 18.2 * -15.25 * 0.0001 + * 42.0 * 0.012 - 8.45 + 0 + 88.0 + 6.96 + 867.0 + 9.10 - 7.04 * -1.0);