public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "law at redhat dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/15855] [3.4/4.0 Regression] g++ crash with -O2 and -O3 on input file Date: Sat, 27 Nov 2004 07:50:00 -0000 [thread overview] Message-ID: <20041127074956.9214.qmail@sourceware.org> (raw) In-Reply-To: <20040606191038.15855.abegel@cs.berkeley.edu> ------- Additional Comments From law at redhat dot com 2004-11-27 07:49 ------- Subject: Re: [3.4/4.0 Regression] g++ crash with -O2 and -O3 on input file It's always amazing to see how such simple oversights can result in such a dramatic difference in the code we generate and to a smaller extent our compile-time performance. For this PR we actually spend considerable time compiling the the static initialization and destruction routine. Yes, that's right... The C++ front-end presents us with code like this: <<< Unknown tree: if_stmt __priority == 65535 && __initialize_p == 1 <<cleanup_point <<< Unknown tree: expr_stmt __comp_ctor (&__ioinit) >>> >> >>> ; <<< Unknown tree: if_stmt __priority == 65535 && __initialize_p == 1 <<cleanup_point <<< Unknown tree: expr_stmt __comp_ctor (&phylum_info, 131, (const char *) "trans_unit", 3, 0, 1, 0, 0, 0, 0, 1, 1) >>> >> >>> ; Which repeats over and over and over (around a thousand times). The if conditions remain the same, but the actions within the IF statement change. We gimplify that into: if (__priority == 65535) { if (__initialize_p == 1) { __comp_ctor (&__ioinit); } else { } } else { } if (__priority == 65535) { if (__initialize_p == 1) { __comp_ctor (&phylum_info, 131, &"trans_unit"[0], 3, 0, 1, 0, 0, 0, 0, 1, 1); } else { } } [ ... ] It doesn't take a rocket scientist to realize that we've got a lot of redundant tests in this code and it really should look something like if (__priority == 65535) if (__initialize == 1) { action1; action2; ... actionN; } When I looked at the DOM1 dump file I was rather annoyed to find that while it successfully threaded away all the __priority tests, but left in all the __initialize tests. Ugh. That can't be good. I was pleasantly surprised to see that one iteration of DOM was sufficient to do all the threading of the __priority tests, that's good from a compile-time performance standpoint. What I was surprised to find was that DOM1 did not iterate! Thus it didn't thread all the __initialize tests until DOM2. cleanup_tree_cfg didn't find any control statements to remove, unreachable blocks or jumps to thread. So it returned false. It did however merge roughly a thousand blocks. But we do not propagate that to the callers of cleanup_tree_cfg. Which is the root of the problem. DOM's jump threader doesn't look through multiple blocks. So while block merging won't expose new control flow cleanups, unreachable blocks or jump threads for cleanup_tree_cfg, it may expose new jump threading opportunities for DOM's jump threader. Fixing this little oversight resulted in DOM1 threading all the conditional in the target function leaving us with optimal code in a total of 4 basic blocks. And the best news of all, this _improves_ compile time performance for this testcase (by about a percent). Bootstrapped and regression tested on i686-pc-linux-gnu. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15855
next prev parent reply other threads:[~2004-11-27 7:50 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-06-06 19:10 [Bug c++/15855] New: " abegel at cs dot berkeley dot edu 2004-06-06 19:12 ` [Bug c++/15855] " abegel at cs dot berkeley dot edu 2004-06-06 19:18 ` pinskia at gcc dot gnu dot org 2004-06-06 19:25 ` pinskia at gcc dot gnu dot org 2004-06-06 19:39 ` abegel at cs dot berkeley dot edu 2004-08-15 3:27 ` [Bug rtl-optimization/15855] " pinskia at gcc dot gnu dot org 2004-08-15 3:28 ` [Bug rtl-optimization/15855] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org 2004-08-29 18:47 ` mmitchel at gcc dot gnu dot org 2004-10-12 13:26 ` [Bug rtl-optimization/15855] [3.4/4.0 " pinskia at gcc dot gnu dot org 2004-10-12 13:28 ` [Bug c++/15855] " pinskia at gcc dot gnu dot org 2004-10-12 13:29 ` [Bug middle-end/15855] " pinskia at gcc dot gnu dot org 2004-11-01 0:45 ` mmitchel at gcc dot gnu dot org 2004-11-21 5:33 ` pinskia at gcc dot gnu dot org 2004-11-21 5:54 ` pinskia at gcc dot gnu dot org 2004-11-23 3:49 ` pinskia at gcc dot gnu dot org 2004-11-23 3:51 ` giovannibajo at libero dot it 2004-11-25 20:29 ` pinskia at gcc dot gnu dot org 2004-11-26 16:01 ` pinskia at gcc dot gnu dot org 2004-11-27 7:50 ` law at redhat dot com [this message] 2004-11-27 8:18 ` giovannibajo at libero dot it 2004-11-27 16:57 ` law at redhat dot com 2004-11-28 23:52 ` giovannibajo at libero dot it 2004-12-01 18:32 ` rth at redhat dot com 2004-12-02 6:09 ` rth at redhat dot com 2004-12-02 15:57 ` law at redhat dot com 2004-12-22 19:20 ` steven at gcc dot gnu dot org 2004-12-22 19:29 ` law at redhat dot com 2005-05-19 17:23 ` [Bug middle-end/15855] [3.4/4.0/4.1 " mmitchel at gcc dot gnu dot org 2005-07-22 21:16 ` pinskia at gcc dot gnu dot org 2005-07-24 1:00 ` pinskia at gcc dot gnu dot org 2005-08-12 6:21 ` phython at gcc dot gnu dot org 2005-08-12 19:08 ` wilson at specifix dot com 2005-09-12 10:53 ` rguenth at gcc dot gnu dot org 2005-09-15 22:06 ` rguenth at gcc dot gnu dot org 2005-09-16 8:14 ` rguenth at gcc dot gnu dot org 2005-09-26 8:39 ` cvs-commit at gcc dot gnu dot org 2005-09-26 8:43 ` cvs-commit at gcc dot gnu dot org 2005-09-27 15:59 ` mmitchel at gcc dot gnu dot org
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=20041127074956.9214.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).