[PATCH v2 3/3] add more testcases for AND/OR simplification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a few testcases showing the effectiveness of these
simplifications and to catch possible future regressions.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/optim/and-lsr-or-shl0.c | 13 +++++++++++++
 validation/optim/and-lsr-or-shl1.c | 13 +++++++++++++
 validation/optim/and-shl-or-lsr0.c | 13 +++++++++++++
 validation/optim/lsr-or-lsr0.c     | 22 ++++++++++++++++++++++
 validation/optim/trunc-or-shl0.c   | 22 ++++++++++++++++++++++
 5 files changed, 83 insertions(+)
 create mode 100644 validation/optim/and-lsr-or-shl0.c
 create mode 100644 validation/optim/and-lsr-or-shl1.c
 create mode 100644 validation/optim/and-shl-or-lsr0.c
 create mode 100644 validation/optim/lsr-or-lsr0.c
 create mode 100644 validation/optim/trunc-or-shl0.c

diff --git a/validation/optim/and-lsr-or-shl0.c b/validation/optim/and-lsr-or-shl0.c
new file mode 100644
index 000000000000..46ab1bde5249
--- /dev/null
+++ b/validation/optim/and-lsr-or-shl0.c
@@ -0,0 +1,13 @@
+// =>	0
+unsigned int and_lsr_or_shl0(unsigned int a, unsigned int b)
+{
+	return ((a | b << 12) >> 12) & 0xfff00000;
+}
+
+/*
+ * check-name: and-lsr-or-shl0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-excludes: shl\\.
+ */
diff --git a/validation/optim/and-lsr-or-shl1.c b/validation/optim/and-lsr-or-shl1.c
new file mode 100644
index 000000000000..22fee362b16b
--- /dev/null
+++ b/validation/optim/and-lsr-or-shl1.c
@@ -0,0 +1,13 @@
+// =>	(((a | b << 12) >> 12)
+unsigned int and_lsr_or_shl1(unsigned int a, unsigned int b)
+{
+	return ((a | b << 12) >> 12) & 0x000fffff;
+}
+
+/*
+ * check-name: and-lsr-or-shl1
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-excludes: shl\\.
+ */
diff --git a/validation/optim/and-shl-or-lsr0.c b/validation/optim/and-shl-or-lsr0.c
new file mode 100644
index 000000000000..f2a7cc631258
--- /dev/null
+++ b/validation/optim/and-shl-or-lsr0.c
@@ -0,0 +1,13 @@
+unsigned and_shl_or_lsr0(unsigned a, unsigned b)
+{
+	return ((a | (b >> 12)) << 12) & 0xfff00000;
+}
+
+/*
+ * check-name: and-shl-or-lsr0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/lsr-or-lsr0.c b/validation/optim/lsr-or-lsr0.c
new file mode 100644
index 000000000000..aad4aa7fda56
--- /dev/null
+++ b/validation/optim/lsr-or-lsr0.c
@@ -0,0 +1,22 @@
+#define	S	12
+
+//	((x >> S') | y) >> S;
+// ->	((x >> S' >> S) | (y >> S)
+// ->	((x >> 32) | (y >> S)
+// =>	(y >> S)
+
+int lsr_or_lsr0(unsigned int x, unsigned int b)
+{
+	return ((x >> (32 - S)) | b) >> S;
+}
+
+/*
+ * check-name: lsr-or-lsr0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): lsr\\.
+ * check-output-excludes: and\\.
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/trunc-or-shl0.c b/validation/optim/trunc-or-shl0.c
new file mode 100644
index 000000000000..ab92aca1b711
--- /dev/null
+++ b/validation/optim/trunc-or-shl0.c
@@ -0,0 +1,22 @@
+// => TRUNC(b, 8)
+char trunc_or_shl0a(unsigned a, unsigned b)
+{
+	return (a << 8) | b;
+}
+
+// => TRUNC(a, 8)
+char trunc_or_shl0b(unsigned a, unsigned b)
+{
+	return a | (b << 8);
+}
+
+/*
+ * check-name: trunc-or-shl0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: or\\.
+ * check-output-excludes: shl\\.
+ * check-output-pattern(2): %arg
+ */
-- 
2.28.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux