* [PATCH] c: Fix compile time hog in c_genericize [PR107127]
@ 2022-11-23 8:59 Jakub Jelinek
2022-11-23 17:49 ` Joseph Myers
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2022-11-23 8:59 UTC (permalink / raw)
To: Joseph S. Myers, Marek Polacek; +Cc: gcc-patches
Hi!
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.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2022-11-23 Andrew Pinski <apinski@marvell.com>
Jakub Jelinek <jakub@redhat.com>
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.
--- gcc/c-family/c-gimplify.cc.jj 2022-08-12 13:39:59.229218070 +0200
+++ gcc/c-family/c-gimplify.cc 2022-11-22 11:48:39.977263700 +0100
@@ -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 ();
}
--- gcc/testsuite/gcc.dg/pr107127.c.jj 2022-11-22 11:56:20.798454526 +0100
+++ gcc/testsuite/gcc.dg/pr107127.c 2022-11-22 11:56:06.224669767 +0100
@@ -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);
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c: Fix compile time hog in c_genericize [PR107127]
2022-11-23 8:59 [PATCH] c: Fix compile time hog in c_genericize [PR107127] Jakub Jelinek
@ 2022-11-23 17:49 ` Joseph Myers
0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2022-11-23 17:49 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Marek Polacek, gcc-patches
On Wed, 23 Nov 2022, Jakub Jelinek via Gcc-patches wrote:
> Hi!
>
> 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.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2022-11-23 Andrew Pinski <apinski@marvell.com>
> Jakub Jelinek <jakub@redhat.com>
>
> 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.
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-23 17:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 8:59 [PATCH] c: Fix compile time hog in c_genericize [PR107127] Jakub Jelinek
2022-11-23 17:49 ` Joseph Myers
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).