aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-01-31 14:51:33 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-03-10 15:27:19 +0100
commitb9429057955ed194b072ca181d61c47c562ebcaa (patch)
treeb70f4218fb3240f7f4225b180062e587336c450f
parent520454ec595c50050740d9375047c897f1cf3339 (diff)
downloadsparse-b9429057955ed194b072ca181d61c47c562ebcaa.tar.gz
add testcases for constant compares against AND/OR
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--validation/optim/cmpe-and0.c11
-rw-r--r--validation/optim/cmpe-or0.c11
-rw-r--r--validation/optim/cmps-and0.c22
-rw-r--r--validation/optim/cmps-or0.c22
-rw-r--r--validation/optim/cmps0-and0.c13
-rw-r--r--validation/optim/cmpu-and0.c18
-rw-r--r--validation/optim/cmpu-or0.c19
7 files changed, 116 insertions, 0 deletions
diff --git a/validation/optim/cmpe-and0.c b/validation/optim/cmpe-and0.c
new file mode 100644
index 00000000..7db60836
--- /dev/null
+++ b/validation/optim/cmpe-and0.c
@@ -0,0 +1,11 @@
+int cmpe_and_eq(int a) { return ((a & 0xff00) == 0xff01) + 1; }
+int cmpe_and_ne(int a) { return ((a & 0xff00) != 0xff01) + 0; }
+
+/*
+ * check-name: cmpe-and0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/cmpe-or0.c b/validation/optim/cmpe-or0.c
new file mode 100644
index 00000000..bef23161
--- /dev/null
+++ b/validation/optim/cmpe-or0.c
@@ -0,0 +1,11 @@
+int cmp_eq(int a) { return ((a | 1) != 0) + 0; }
+int cmp_ne(int a) { return ((a | 1) == 0) + 1; }
+
+/*
+ * check-name: cmpe-or0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/cmps-and0.c b/validation/optim/cmps-and0.c
new file mode 100644
index 00000000..097ec2f9
--- /dev/null
+++ b/validation/optim/cmps-and0.c
@@ -0,0 +1,22 @@
+#define MINUS_ONE -1
+#define MASK 32
+
+
+int cmps_and_lt_lt0(int a) { return ((a & MASK) < MINUS_ONE) + 1; }
+int cmps_and_lt_gtm(int a) { return ((a & MASK) < (MASK + 1)) + 0; }
+int cmps_and_le_lt0(int a) { return ((a & MASK) <= MINUS_ONE) + 1; }
+int cmps_and_le_gtm(int a) { return ((a & MASK) <= (MASK + 1)) + 0; }
+
+int cmps_and_gt_lt0(int a) { return ((a & MASK) > MINUS_ONE) + 0; }
+int cmps_and_gt_gtm(int a) { return ((a & MASK) > (MASK + 1)) + 1; }
+int cmps_and_ge_lt0(int a) { return ((a & MASK) >= MINUS_ONE) + 0; }
+int cmps_and_ge_gtm(int a) { return ((a & MASK) >= (MASK + 1)) + 1; }
+
+/*
+ * check-name: cmps-and0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/cmps-or0.c b/validation/optim/cmps-or0.c
new file mode 100644
index 00000000..40a2092c
--- /dev/null
+++ b/validation/optim/cmps-or0.c
@@ -0,0 +1,22 @@
+#define EQ(X) + (X == 0)
+#define SIGN (1 << 31)
+#define MASK (SIGN | 32)
+
+
+int cmps_ior_lt_x(int a) { return ((a | MASK) < 4) EQ(1); }
+int cmps_ior_lt_0(int a) { return ((a | MASK) < 0) EQ(1); }
+int cmps_ior_le_x(int a) { return ((a | MASK) <= 4) EQ(1); }
+int cmps_ior_le_0(int a) { return ((a | MASK) <= 0) EQ(1); }
+int cmps_ior_ge_x(int a) { return ((a | MASK) >= 4) EQ(0); }
+int cmps_ior_ge_0(int a) { return ((a | MASK) >= 0) EQ(0); }
+int cmps_ior_gt_x(int a) { return ((a | MASK) > 4) EQ(0); }
+int cmps_ior_gt_0(int a) { return ((a | MASK) > 0) EQ(0); }
+
+/*
+ * check-name: cmps-or0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/cmps0-and0.c b/validation/optim/cmps0-and0.c
new file mode 100644
index 00000000..819a1dc2
--- /dev/null
+++ b/validation/optim/cmps0-and0.c
@@ -0,0 +1,13 @@
+#define M 32
+
+int cmps_and_sle0(int a) { return ((a & M) <= 0) == ((a & M) == 0); }
+int cmps_and_sgt0(int a) { return ((a & M) > 0) == ((a & M) != 0); }
+
+/*
+ * check-name: cmps0-and
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/cmpu-and0.c b/validation/optim/cmpu-and0.c
new file mode 100644
index 00000000..25321294
--- /dev/null
+++ b/validation/optim/cmpu-and0.c
@@ -0,0 +1,18 @@
+#define MASK 32U
+
+
+int cmps_and_ltu_gt(int a) { return ((a & MASK) < (MASK + 1)) + 0; }
+int cmps_and_leu_gt(int a) { return ((a & MASK) <= (MASK + 1)) + 0; }
+int cmps_and_leu_eq(int a) { return ((a & MASK) <= (MASK + 0)) + 0; }
+int cmps_and_geu_gt(int a) { return ((a & MASK) >= (MASK + 1)) + 1; }
+int cmps_and_gtu_gt(int a) { return ((a & MASK) > (MASK + 1)) + 1; }
+int cmps_and_gtu_eq(int a) { return ((a & MASK) > (MASK + 0)) + 1; }
+
+/*
+ * check-name: cmpu-and0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/cmpu-or0.c b/validation/optim/cmpu-or0.c
new file mode 100644
index 00000000..77360d3f
--- /dev/null
+++ b/validation/optim/cmpu-or0.c
@@ -0,0 +1,19 @@
+#define EQ(X) + (X == 0)
+#define MASK 32U
+
+
+int cmpu_ior_lt_lt(int a) { return ((a | MASK) < (MASK - 1)) EQ(0); }
+int cmpu_ior_lt_eq(int a) { return ((a | MASK) < (MASK )) EQ(0); }
+int cmpu_ior_le_lt(int a) { return ((a | MASK) <= (MASK - 1)) EQ(0); }
+int cmpu_ior_ge_lt(int a) { return ((a | MASK) >= (MASK - 1)) EQ(1); }
+int cmpu_ior_ge_eq(int a) { return ((a | MASK) >= (MASK )) EQ(1); }
+int cmpu_ior_gt_lt(int a) { return ((a | MASK) > (MASK - 1)) EQ(1); }
+
+/*
+ * check-name: cmpu-or0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */