linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 2/9] add testcases for constant compares against AND/OR
Date: Wed, 10 Mar 2021 22:49:43 +0100	[thread overview]
Message-ID: <20210310214950.84192-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20210310214950.84192-1-luc.vanoostenryck@gmail.com>

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 validation/optim/cmpe-and0.c  | 11 +++++++++++
 validation/optim/cmpe-or0.c   | 11 +++++++++++
 validation/optim/cmps-and0.c  | 22 ++++++++++++++++++++++
 validation/optim/cmps-or0.c   | 22 ++++++++++++++++++++++
 validation/optim/cmps0-and0.c | 13 +++++++++++++
 validation/optim/cmpu-and0.c  | 18 ++++++++++++++++++
 validation/optim/cmpu-or0.c   | 19 +++++++++++++++++++
 7 files changed, 116 insertions(+)
 create mode 100644 validation/optim/cmpe-and0.c
 create mode 100644 validation/optim/cmpe-or0.c
 create mode 100644 validation/optim/cmps-and0.c
 create mode 100644 validation/optim/cmps-or0.c
 create mode 100644 validation/optim/cmps0-and0.c
 create mode 100644 validation/optim/cmpu-and0.c
 create mode 100644 validation/optim/cmpu-or0.c

diff --git a/validation/optim/cmpe-and0.c b/validation/optim/cmpe-and0.c
new file mode 100644
index 000000000000..7db608365568
--- /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 000000000000..bef2316120f7
--- /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 000000000000..097ec2f9f16c
--- /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 000000000000..40a2092c58a4
--- /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 000000000000..819a1dc2a793
--- /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 000000000000..253212941779
--- /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 000000000000..77360d3feb0f
--- /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
+ */
-- 
2.30.0


  parent reply	other threads:[~2021-03-10 22:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 21:49 [PATCH 0/9] simplify CMP(AND(x,M), C) and CMP(OR(x,M), C) Luc Van Oostenryck
2021-03-10 21:49 ` [PATCH 1/9] change testing of signed compares against SMIN or SMAX Luc Van Oostenryck
2021-03-10 21:49 ` Luc Van Oostenryck [this message]
2021-03-10 21:49 ` [PATCH 3/9] simplify (x & M) cmps C Luc Van Oostenryck
2021-03-10 21:49 ` [PATCH 4/9] simplify (x & M) cmpu C Luc Van Oostenryck
2021-03-10 21:49 ` [PATCH 5/9] simplify (x & M) cmps 0 Luc Van Oostenryck
2021-03-10 21:49 ` [PATCH 6/9] simplify (x & M) {==,!=} C Luc Van Oostenryck
2021-03-10 21:49 ` [PATCH 7/9] simplify (x | " Luc Van Oostenryck
2021-03-10 21:49 ` [PATCH 8/9] simplify (x | M) cmps C Luc Van Oostenryck
2021-03-10 21:49 ` [PATCH 9/9] simplify (x | M) cmpu C Luc Van Oostenryck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210310214950.84192-3-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).