https://gcc.gnu.org/g:82a2f1386b2e8c951e910e1096a04bed21bbd39b

commit r15-3039-g82a2f1386b2e8c951e910e1096a04bed21bbd39b
Author: Andrew Pinski <quic_apin...@quicinc.com>
Date:   Mon Aug 12 15:13:04 2024 -0700

    testsuite: Add testcases for part of PR 103660
    
    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_apin...@quicinc.com>

Diff:
---
 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(+)

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" } } */

Reply via email to