public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20912] New: C++ FE emitting assignments to read-only global symbols
@ 2005-04-09  1:52 dnovillo at gcc dot gnu dot org
  2005-04-09 12:48 ` [Bug c++/20912] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: dnovillo at gcc dot gnu dot org @ 2005-04-09  1:52 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2007-05-04  0:30 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-20912-91@http.gcc.gnu.org/bugzilla/>
2005-10-11  7:21 ` [Bug c++/20912] C++ FE emitting assignments to read-only global symbols mmitchel at gcc dot gnu dot org
2005-10-11 21:06 ` mmitchel at gcc dot gnu dot org
2005-10-11 21:07 ` mmitchel at gcc dot gnu dot org
2005-10-12 14:16 ` dnovillo at redhat dot com
2005-10-12 14:55 ` mark at codesourcery dot com
2005-10-12 15:00 ` dnovillo at redhat dot com
2005-10-28 18:25 ` pinskia at gcc dot gnu dot org
2007-02-03 18:36 ` steven at gcc dot gnu dot org
2007-02-05  3:19 ` mark at codesourcery dot com
2007-02-05 22:30 ` steven at gcc dot gnu dot org
2007-02-05 22:46 ` steven at gcc dot gnu dot org
2007-02-05 22:51 ` rguenth at gcc dot gnu dot org
2007-02-05 22:51 ` rguenth at gcc dot gnu dot org
2007-02-07  0:56 ` schlie at comcast dot net
2007-05-04  0:30 ` pinskia at gcc dot gnu dot org
2005-04-09  1:52 [Bug c++/20912] New: " dnovillo at gcc dot gnu dot org
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

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).