diff mbox series

[1/3] testsuite: Add testcases for part of PR 103660

Message ID 20240813043023.3685386-1-quic_apinski@quicinc.com
State New
Headers show
Series [1/3] testsuite: Add testcases for part of PR 103660 | expand

Commit Message

Andrew Pinski Aug. 13, 2024, 4:30 a.m. UTC
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 | 28 ++++++++++++++
 gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C | 28 ++++++++++++++
 gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c | 33 +++++++++++++++++
 gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c | 43 ++++++++++++++++++++++
 4 files changed, 132 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C
 create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c

Comments

Richard Biener Aug. 20, 2024, 8:33 a.m. UTC | #1
On Tue, Aug 13, 2024 at 6:31 AM Andrew Pinski <quic_apinski@quicinc.com> wrote:
>
> 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.

OK.

>         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 | 28 ++++++++++++++
>  gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C | 28 ++++++++++++++
>  gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c | 33 +++++++++++++++++
>  gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c | 43 ++++++++++++++++++++++
>  4 files changed, 132 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C
>  create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c
>
> 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
> index 00000000000..766ec92457c
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C
> @@ -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
> index 00000000000..713057586f2
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C
> @@ -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
> index 00000000000..6be0721aedd
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c
> @@ -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
> index 00000000000..f3c207cf6c4
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c
> @@ -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" } } */
> --
> 2.43.0
>
diff mbox series

Patch

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
index 00000000000..766ec92457c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C
@@ -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
index 00000000000..713057586f2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C
@@ -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
index 00000000000..6be0721aedd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c
@@ -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
index 00000000000..f3c207cf6c4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c
@@ -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" } } */