]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Add C++ testcase for PR 126296: `<=>` folding into `<>`.
authorAndrea Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 27 Jul 2026 22:06:07 +0000 (15:06 -0700)
committerAndrea Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 27 Jul 2026 22:13:05 +0000 (15:13 -0700)
This adds 2 testcases for fp: `(i <=> j > 0) | (i <=> j < 0)`.
The trapping version was fixed by r17-2709-gde8be0eb05d951
while the non-trapping version was fixed earlier by
r17-2129-gea8c74c074925b.
Since we didn't have a testcase for these cases before,
it would be a good idea to have them.

Pushed as obvious after testing to make sure they work on x86_64-linux-gnu.

PR tree-optimization/126296

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr126296-1.C: New test.
* g++.dg/tree-ssa/pr126296-2.C: New test.

Signed-off-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com>
gcc/testsuite/g++.dg/tree-ssa/pr126296-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/tree-ssa/pr126296-2.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr126296-1.C b/gcc/testsuite/g++.dg/tree-ssa/pr126296-1.C
new file mode 100644 (file)
index 0000000..9859d4b
--- /dev/null
@@ -0,0 +1,20 @@
+// PR tree-optimization/126296
+// { dg-do compile { target c++20 } }
+// { dg-options "-O2 -g0 -ftrapping-math -fdump-tree-optimized" }
+// { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) <> \[ij]_\[0-9]+\\(D\\)" 1 "optimized" } }
+// { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) <> 5\\.0" 1 "optimized" } }
+// { dg-final { scan-tree-dump-not "if " "optimized" } }
+
+#include <compare>
+
+#define A __attribute__((noipa))
+A bool f1 (double i, double j)
+{
+  auto c = i <=> j;
+  return (c < 0) | (c > 0);
+}
+A bool f2 (double i)
+{
+  auto c = i <=> 5.0;
+  return (c < 0) | (c > 0);
+}
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr126296-2.C b/gcc/testsuite/g++.dg/tree-ssa/pr126296-2.C
new file mode 100644 (file)
index 0000000..bbddf88
--- /dev/null
@@ -0,0 +1,20 @@
+// PR tree-optimization/126296
+// { dg-do compile { target c++20 } }
+// { dg-options "-O2 -g0 -fno-trapping-math -fdump-tree-optimized" }
+// { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) <> \[ij]_\[0-9]+\\(D\\)" 1 "optimized" } }
+// { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) <> 5\\.0" 1 "optimized" } }
+// { dg-final { scan-tree-dump-not "if " "optimized" } }
+
+#include <compare>
+
+#define A __attribute__((noipa))
+A bool f1 (double i, double j)
+{
+  auto c = i <=> j;
+  return (c < 0) | (c > 0);
+}
+A bool f2 (double i)
+{
+  auto c = i <=> 5.0;
+  return (c < 0) | (c > 0);
+}