diff mbox series

[v2,08/10] Test: Add testcases for form 6 of unsigned integer SAT_ADD simplify

Message ID 20241031062742.2709845-8-pan2.li@intel.com
State New
Headers show
Series [v2,01/10] Match: Simplify branch form 4 of unsigned SAT_ADD into branchless | expand

Commit Message

Li, Pan2 Oct. 31, 2024, 6:27 a.m. UTC
From: Pan Li <pan2.li@intel.com>

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

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pan Li <pan2.li@intel.com>
---
 gcc/testsuite/gcc.dg/sat_arith_simplify.h       |  9 +++++++++
 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u16.c | 11 +++++++++++
 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u32.c | 11 +++++++++++
 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u64.c | 11 +++++++++++
 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u8.c  | 11 +++++++++++
 5 files changed, 53 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u16.c
 create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u32.c
 create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u64.c
 create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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 34fae32ae3a..d577adb9a88 100644
--- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h
+++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h
@@ -34,4 +34,13 @@  T sat_u_add_##T##_1 (T x, T y)  \
     return -1;                  \
 }
 
+#define DEF_SAT_U_ADD_6(T)      \
+T sat_u_add_##T##_6 (T x, T y)  \
+{                               \
+  if ((T)(x + y) < x)           \
+    return -1;                  \
+  else                          \
+    return x + y;               \
+}
+
 #endif
diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u16.c
new file mode 100644
index 00000000000..83e6a8993b3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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-6-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u32.c
new file mode 100644
index 00000000000..622206486e5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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-6-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u64.c
new file mode 100644
index 00000000000..f8ea3c8767a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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-6-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u8.c
new file mode 100644
index 00000000000..bcd136d899f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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" } } */