]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/113896 - testcase for fixed PR
authorRichard Biener <rguenther@suse.de>
Tue, 13 Feb 2024 12:39:29 +0000 (13:39 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 13 Feb 2024 12:42:02 +0000 (13:42 +0100)
The SLP permute optimization rewrite fixed this.

PR tree-optimization/113896
* g++.dg/torture/pr113896.C: New testcase.

gcc/testsuite/g++.dg/torture/pr113896.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/torture/pr113896.C b/gcc/testsuite/g++.dg/torture/pr113896.C
new file mode 100644 (file)
index 0000000..534c1c2
--- /dev/null
@@ -0,0 +1,35 @@
+// { dg-do run }
+// { dg-additional-options "-ffast-math" }
+
+double a1 = 1.0;
+double a2 = 1.0;
+
+void __attribute__((noipa))
+f(double K[2], bool b)
+{
+    double A[] = {
+        b ? a1 : a2,
+        0,
+        0,
+        0
+    };
+
+    double sum{};
+    for(double  a : A) sum += a;
+    for(double& a : A) a /= sum;
+
+    if (b) {
+        K[0] = A[0]; // 1.0
+        K[1] = A[1]; // 0.0
+    } else {
+        K[0] = A[0] + A[1];
+    }
+}
+
+int main()
+{
+  double K[2]{};
+  f(K, true);
+  if (K[0] != 1. || K[1] != 0.)
+    __builtin_abort ();
+}