public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "dnovillo at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/20912] New: C++ FE emitting assignments to read-only global symbols Date: Sat, 09 Apr 2005 01:52:00 -0000 [thread overview] Message-ID: <20050409015142.20912.dnovillo@gcc.gnu.org> (raw) One of the micro-optimizations that may be done inside the tree optimizer involves disregarding V_MAY_DEF/V_MUST_DEF operands for read-only globals. So, if a symbol is marked read-only and the operand scanner requests a V_MAY_DEF or V_MUST_DEF operand for it, we replace it with a VUSE. This works fine, except that I was having comparison errors with SPEC2000's eon. I tracked it down to the C++ FE emitting an assignment instruction for a global const variable. The source code declares const double ggPi = 3.14159265358979323846; double const divPi = 1 / ggPi; And since divPi is initialized to an expression, I guess it needs to compute it at runtime, so it emits an initialization function: void __static_initialization_and_destruction_0(int, int) (__initialize_p, __priority) { ... if (D.55019) { ggPi.319 = ggPi; D.55021 = 1.0e+0 / ggPi.319; divPi = D.55021; } ... } So, we now have an assignment for divPi in the IL stream. This throws a monkey wrench into this micro-optimization because it shouldn't really have ignored that V_MUST_DEF (the tree optimizers end up removing the assignment). This optimization is currently disabled because of this. If the C++ FE is fixed to address this problem, the following patch will re-enable the optimization: --- tree-ssa-operands.c 9 Apr 2005 01:37:24 -0000 2.75 +++ tree-ssa-operands.c 9 Apr 2005 01:51:02 -0000 @@ -1803,14 +1803,8 @@ add_stmt_operand (tree *var_p, stmt_ann_ it into a VUSE. This happens when read-only variables are marked call-clobbered and/or aliased to writeable variables. So we only check that this only happens on stores, and not writes to GIMPLE - registers. - - FIXME: The C++ FE is emitting assignments in the IL stream for - read-only globals. This is wrong, but for the time being disable - this transformation on V_MUST_DEF operands (otherwise, we - mis-optimize SPEC2000's eon). */ + registers. */ if ((flags & opf_is_def) - && !(flags & opf_kill_def) && unmodifiable_var_p (var)) { gcc_assert (!is_real_op); -- Summary: C++ FE emitting assignments to read-only global symbols Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dnovillo at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org,mark at codesourcery dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20912
next reply other threads:[~2005-04-09 1:52 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-04-09 1:52 dnovillo at gcc dot gnu dot org [this message] 2005-04-09 12:48 ` [Bug c++/20912] " pinskia at gcc dot gnu dot org 2005-04-14 21:29 ` schlie at comcast dot net 2005-04-18 17:56 ` pinskia at gcc dot gnu dot org 2005-04-18 19:29 ` schlie at comcast dot net 2005-04-28 2:11 ` pinskia at gcc dot gnu dot org 2005-04-28 2:46 ` matz at suse dot de 2005-07-18 4:42 ` pinskia 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=20050409015142.20912.dnovillo@gcc.gnu.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).