aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-03-27 14:30:47 +0200
committerRichard Biener <rguenther@suse.de>2023-03-27 14:32:07 +0200
commitbff7c6f70166ee71ff6e42f58663dc255e4bc079 (patch)
tree103375491771825a52d456c5319bed5b385b49a4 /gcc
parentce4a00e29c71f2f51d52f407ecd265fa40688586 (diff)
downloadgcc-bff7c6f70166ee71ff6e42f58663dc255e4bc079.zip
gcc-bff7c6f70166ee71ff6e42f58663dc255e4bc079.tar.gz
gcc-bff7c6f70166ee71ff6e42f58663dc255e4bc079.tar.bz2
tree-optimization/54498 - testcase for the bug
I realized I never added a testcase for the fix of this bug. Now done after verifying it still fails when reverting the fix. PR tree-optimization/54498 * g++.dg/torture/pr54498.C: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/g++.dg/torture/pr54498.C57
1 files changed, 57 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/torture/pr54498.C b/gcc/testsuite/g++.dg/torture/pr54498.C
new file mode 100644
index 0000000..74651f9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr54498.C
@@ -0,0 +1,57 @@
+// { dg-do run }
+// { dg-additional-options "-fno-tree-sra" }
+
+#include <complex>
+
+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);
+ }
+ if (i > 0)
+ {
+ double a = abs(ft - prev_ft);
+ if (a < 0.024 || a > 0.025)
+ __builtin_abort ();
+ }
+ }
+}
+
+int main()
+{
+ foo();
+ return 0;
+}