public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/54498] [4.7/4.8 Regression] incorrect code generation from g++ -O
Date: Wed, 05 Sep 2012 22:22:00 -0000	[thread overview]
Message-ID: <bug-54498-4-7typTmRUQZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-54498-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54498

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2012-09-05
          Component|c++                         |tree-optimization
     Ever Confirmed|0                           |1
            Summary|incorrect code generation   |[4.7/4.8 Regression]
                   |from g++ -O on x86_64       |incorrect code generation
                   |                            |from g++ -O
   Target Milestone|---                         |4.7.2

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-09-05 22:21:58 UTC ---
Confirmed, here is the source unincluded:
#include <complex>
#include <cstdio>
using namespace std;

class bar_src {
 public:
  bar_src() : next(0) {}
  virtual ~bar_src() { delete next; }

  bar_src *next;
};

class foo_src : public bar_src {
 public:
  foo_src(double f, double fwidth, double s = 5.0);
  virtual ~foo_src() {}

 private:
  double freq, width, peak_time, cutoff;
};


foo_src::foo_src(double f, double fwidth, double s) {
  freq = f; width = 1/fwidth; cutoff = s*width; peak_time = cutoff;
}

complex<double> do_ft2(int i) __attribute__ ((noinline));

complex<double> do_ft2(int i) {
  return i == 0 ? complex<double>(-491.697,887.05) :
complex<double>(-491.692,887.026);
}

void foo(void) {
  complex<double> prev_ft = 0.0, ft = 0.0;
  for (int i=0; i < 2; i++) {
    prev_ft = ft;
    {
      foo_src src(1.0, 1.0 / 20);
      ft = do_ft2(i);
      printf("ft (it = %d) = %g%+gi\n", i, real(ft), imag(ft));
    }
    if (i > 0)
      printf("abs(ft - prev_ft) = %g\n",
      abs(ft - prev_ft));
  }
}

int main(void) {
  foo();
  return 0;
}

--- CUT ---
The problem comes from FRE, I think due to how it handles look though copies. 
It happens on more than just x86_64.


  reply	other threads:[~2012-09-05 22:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05 21:50 [Bug c++/54498] New: incorrect code generation from g++ -O on x86_64 stevenj at alum dot mit.edu
2012-09-05 22:22 ` pinskia at gcc dot gnu.org [this message]
2012-09-06  9:58 ` [Bug tree-optimization/54498] [4.7/4.8 Regression] incorrect code generation from g++ -O rguenth at gcc dot gnu.org
2012-09-06 10:21 ` rguenth at gcc dot gnu.org
2012-09-06 12:22 ` hjl.tools at gmail dot com
2012-09-06 13:54 ` [Bug tree-optimization/54498] [4.6/4.7/4.8 " rguenth at gcc dot gnu.org
2012-09-06 14:48 ` rguenth at gcc dot gnu.org
2012-09-06 15:20 ` rguenth at gcc dot gnu.org
2012-09-07  8:20 ` [Bug tree-optimization/54498] [4.6 " rguenth at gcc dot gnu.org
2013-04-12 16:30 ` jakub at gcc dot gnu.org
2023-03-27 12:32 ` cvs-commit at gcc dot gnu.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=bug-54498-4-7typTmRUQZ@http.gcc.gnu.org/bugzilla/ \
    --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: link
Be 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).