]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Add testcases for part of PR 103660
authorAndrew Pinski <quic_apinski@quicinc.com>
Mon, 12 Aug 2024 22:13:04 +0000 (15:13 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Tue, 20 Aug 2024 13:59:14 +0000 (06:59 -0700)
IOR part of the bug report was fixed by r13-4620-g4d9db4bdd458 but
that added only aarch64 specific testcases. This adds 4
generic testcases for this to check to make sure they are optimized.
The C++ testcases are the vector type versions.

PR tree-optimization/103660

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr103660-0.C: New test.
* g++.dg/tree-ssa/pr103660-1.C: New test.
* gcc.dg/tree-ssa/pr103660-0.c: New test.
* gcc.dg/tree-ssa/pr103660-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C [new file with mode: 0644]
gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C b/gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C
new file mode 100644 (file)
index 0000000..766ec92
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR tree-optimization/103660 */
+/* Vector type version. */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-forwprop1-raw -Wno-psabi" } */
+
+typedef int v4si __attribute((__vector_size__(4 * sizeof(int))));
+#define funcs(OP,n)                    \
+v4si min_##n(v4si a, v4si b) {         \
+  v4si X = -(a < b) * a;               \
+  v4si Y = -(a >= b) * b;              \
+  return (X OP Y);                     \
+}                                      \
+v4si f_##n(v4si a, v4si b,             \
+          v4si c, v4si d) {            \
+  v4si X = -(a < b) * c;               \
+  v4si Y = -(a >= b) * d;              \
+  return (X OP Y);                     \
+}
+
+
+funcs(|, ior)
+
+/* min_ior should produce min<a,b> or `a < b ? a : b` depending on if the target
+   supports min on the vector type or not. */
+/* f_ior should produce (a < b) ? c : d */
+/* { dg-final { scan-tree-dump-not   "bit_ior_expr, "     "forwprop1" } } */
+/* { dg-final { scan-tree-dump-times "(?:lt_expr|min_expr), "        2 "forwprop1" } } */
+/* { dg-final { scan-tree-dump-times "(?:vec_cond_expr|min_expr), "  2 "forwprop1" } } */
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C b/gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C
new file mode 100644 (file)
index 0000000..7130575
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR tree-optimization/103660 */
+/* Vector type version. */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-forwprop1-raw -Wno-psabi" } */
+
+typedef int v4si __attribute((__vector_size__(4 * sizeof(int))));
+#define funcs(OP,n)                    \
+v4si min_##n(v4si a, v4si b) {         \
+  v4si X = a < b ? a : 0;              \
+  v4si Y = a >= b ? b : 0;             \
+  return (X OP Y);                     \
+}                                      \
+v4si f_##n(v4si a, v4si b,             \
+          v4si c, v4si d) {            \
+  v4si X = a < b ? c : 0;              \
+  v4si Y = a >= b ? d : 0;             \
+  return (X OP Y);                     \
+}
+
+
+funcs(|, ior)
+
+/* min_ior should produce min<a,b> or `a < b ? a : b` depending on if the target
+   supports min on the vector type or not. */
+/* f_ior should produce (a < b) ? c : d */
+/* { dg-final { scan-tree-dump-not   "bit_ior_expr, "     "forwprop1" } } */
+/* { dg-final { scan-tree-dump-times "(?:lt_expr|min_expr), "        2 "forwprop1" } } */
+/* { dg-final { scan-tree-dump-times "(?:vec_cond_expr|min_expr), "  2 "forwprop1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c b/gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c
new file mode 100644 (file)
index 0000000..6be0721
--- /dev/null
@@ -0,0 +1,33 @@
+/* PR tree-optimization/103660 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-forwprop4-raw" } */
+
+#define funcs(OP,n)            \
+int min_##n(int a, int b) {    \
+  int t;                       \
+  int t1;                      \
+  int t2;                      \
+  t1 = (a < b) * a;            \
+  t2 = (a >= b) * b;           \
+  t = t1 OP t2;                        \
+  return t;                    \
+}                              \
+int f_##n(int a, int b, int c, \
+        int d) {               \
+  int t;                       \
+  int t1;                      \
+  int t2;                      \
+  t1 = (a < b) * c;            \
+  t2 = (a >= b) * d;           \
+  t = t1 OP t2;                        \
+  return t;                    \
+}
+
+funcs(|, ior)
+
+/* min_ior should produce min<a,b> */
+/* f_ior should produce (a < b) ? c : d */
+/* { dg-final { scan-tree-dump-not   "bit_ior_expr, " "forwprop4" } } */
+/* { dg-final { scan-tree-dump-times "min_expr, "   1 "forwprop4" } } */
+/* { dg-final { scan-tree-dump-times "lt_expr, "    1 "forwprop4" } } */
+/* { dg-final { scan-tree-dump-times "cond_expr, "  1 "forwprop4" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c
new file mode 100644 (file)
index 0000000..f3c207c
--- /dev/null
@@ -0,0 +1,43 @@
+/* PR tree-optimization/103660 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fgimple -fdump-tree-forwprop4-raw" } */
+
+#define funcs(OP,n)            \
+__GIMPLE()                     \
+int min_##n(int a, int b) {    \
+  _Bool X;                     \
+  _Bool Y;                     \
+  int t;                       \
+  int t1;                      \
+  int t2;                      \
+  X = a < b;                   \
+  Y = a >= b;                  \
+  t1 = X ? a : 0;              \
+  t2 = Y ? b : 0;              \
+  t = t1 OP t2;                        \
+  return t;                    \
+}                              \
+__GIMPLE()                     \
+int f_##n(int a, int b, int c, \
+        int d) {               \
+  _Bool X;                     \
+  _Bool Y;                     \
+  int t;                       \
+  int t1;                      \
+  int t2;                      \
+  X = a < b;                   \
+  Y = a >= b;                  \
+  t1 = X ? c : 0;              \
+  t2 = Y ? d : 0;              \
+  t = t1 OP t2;                        \
+  return t;                    \
+}
+
+funcs(|, ior)
+
+/* min_ior should produce min<a,b> */
+/* f_ior should produce (a < b) ? c : d */
+/* { dg-final { scan-tree-dump-not   "bit_ior_expr, " "forwprop4" } } */
+/* { dg-final { scan-tree-dump-times "min_expr, "   1 "forwprop4" } } */
+/* { dg-final { scan-tree-dump-times "lt_expr, "    1 "forwprop4" } } */
+/* { dg-final { scan-tree-dump-times "cond_expr, "  1 "forwprop4" } } */