diff mbox series

[v1,2/5] Test: Add testcases for form 9 of unsigned integer SAT_ADD simplify

Message ID 20241104104924.1743778-2-pan2.li@intel.com
State New
Headers show
Series [v1,1/5] Match: Simplify branch form 5 of unsigned SAT_ADD into branchless | expand

Commit Message

Li, Pan2 Nov. 4, 2024, 10:49 a.m. UTC
From: Pan Li <pan2.li@intel.com>

The phiopt2 pass will also try the gimple_simplify for the form 9
of unsigned integer SAT_ADD.  Thus add the testcase to make sure
it will be performed in phiopt2 pass.

The below test suites are passed for this patch:
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.

gcc/testsuite/ChangeLog:

	* gcc.dg/sat_arith_simplify.h: Add test helper macros.
	* gcc.dg/sat_u_add-simplify-9-u16.c: New test.
	* gcc.dg/sat_u_add-simplify-9-u32.c: New test.
	* gcc.dg/sat_u_add-simplify-9-u64.c: New test.
	* gcc.dg/sat_u_add-simplify-9-u8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
---
 gcc/testsuite/gcc.dg/sat_arith_simplify.h       |  7 +++++++
 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c | 11 +++++++++++
 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c | 11 +++++++++++
 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c | 11 +++++++++++
 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c  | 11 +++++++++++
 5 files changed, 51 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c
 create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c
 create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c
 create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h
index 3d4ec184452..91691c167a0 100644
--- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h
+++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h
@@ -61,4 +61,11 @@  T sat_u_add_##T##_8 (T x, T y)  \
     return x + y;               \
 }
 
+#define DEF_SAT_U_ADD_9(T)                                     \
+T sat_u_add_##T##_9 (T x, T y)                                 \
+{                                                              \
+  T ret;                                                       \
+  return __builtin_add_overflow (x, y, &ret) == 0 ? ret : - 1; \
+}
+
 #endif
diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c
new file mode 100644
index 00000000000..9e93dde6e3f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c
@@ -0,0 +1,11 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */
+
+#include <stdint.h>
+#include "sat_arith_simplify.h"
+
+DEF_SAT_U_ADD_9 (uint16_t)
+
+/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */
+/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */
+/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */
diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c
new file mode 100644
index 00000000000..4dc760ac78c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c
@@ -0,0 +1,11 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */
+
+#include <stdint.h>
+#include "sat_arith_simplify.h"
+
+DEF_SAT_U_ADD_9 (uint32_t)
+
+/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */
+/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */
+/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */
diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c
new file mode 100644
index 00000000000..8748e03e1f5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c
@@ -0,0 +1,11 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */
+
+#include <stdint.h>
+#include "sat_arith_simplify.h"
+
+DEF_SAT_U_ADD_9 (uint64_t)
+
+/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */
+/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */
+/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */
diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c
new file mode 100644
index 00000000000..5cffc43e081
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c
@@ -0,0 +1,11 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */
+
+#include <stdint.h>
+#include "sat_arith_simplify.h"
+
+DEF_SAT_U_ADD_9 (uint8_t)
+
+/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */
+/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */
+/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */