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: Ramsay Jones <ramsay@ramsayjones.plus.com>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH v2 2/3] add more testcases for existing AND/OR simplifications
Date: Sun,  6 Sep 2020 23:16:45 +0200	[thread overview]
Message-ID: <20200906211646.58946-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20200906211646.58946-1-luc.vanoostenryck@gmail.com>

Add a few more testcases to catch possible future regressions.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 validation/optim/and-shl-or-and0.c  | 15 +++++++++++++++
 validation/optim/lsr-or-and0.c      | 22 ++++++++++++++++++++++
 validation/optim/shl-or-constant0.c | 12 ++++++++++++
 validation/optim/shl-or-constant1.c | 12 ++++++++++++
 validation/optim/shl-or-constant2.c | 12 ++++++++++++
 5 files changed, 73 insertions(+)
 create mode 100644 validation/optim/and-shl-or-and0.c
 create mode 100644 validation/optim/lsr-or-and0.c
 create mode 100644 validation/optim/shl-or-constant0.c
 create mode 100644 validation/optim/shl-or-constant1.c
 create mode 100644 validation/optim/shl-or-constant2.c

diff --git a/validation/optim/and-shl-or-and0.c b/validation/optim/and-shl-or-and0.c
new file mode 100644
index 000000000000..298dcb434fc7
--- /dev/null
+++ b/validation/optim/and-shl-or-and0.c
@@ -0,0 +1,15 @@
+// =>	(b << 12) & 0xfff00000
+unsigned and_shl_or_and0(unsigned a, unsigned b)
+{
+	return (((a & 0xfff00000) | b) << 12) & 0xfff00000;
+}
+
+/*
+ * check-name: and-shl-or-and0
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-excludes: or\\.
+ * check-output-excludes: lsr\\.
+ * check-output-excludes: %arg1\\.
+ */
diff --git a/validation/optim/lsr-or-and0.c b/validation/optim/lsr-or-and0.c
new file mode 100644
index 000000000000..fe3a2649eea2
--- /dev/null
+++ b/validation/optim/lsr-or-and0.c
@@ -0,0 +1,22 @@
+#define	S	12
+
+//	((x & M) | b) >> S;
+// ->	((x >> S) & (M >> S)) | (b >> S)
+// but	(M >> S) == 0
+// =>	(b >> S)
+
+int lsr_or_and0a(unsigned int x, unsigned int b)
+{
+	return ((x & 0x00000fff) | b) >> S;
+}
+
+/*
+ * check-name: lsr-or-and0
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-pattern(1): lsr\\.
+ * check-output-excludes: %arg1\\.
+ * check-output-excludes: and\\.
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/shl-or-constant0.c b/validation/optim/shl-or-constant0.c
new file mode 100644
index 000000000000..25347b4b3b20
--- /dev/null
+++ b/validation/optim/shl-or-constant0.c
@@ -0,0 +1,12 @@
+unsigned shl_or_constant0(unsigned a)
+{
+	return (a | 0xfff00000) << 12;
+}
+
+/*
+ * check-name: shl-or-constant0
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/shl-or-constant1.c b/validation/optim/shl-or-constant1.c
new file mode 100644
index 000000000000..cd3ea8bb011b
--- /dev/null
+++ b/validation/optim/shl-or-constant1.c
@@ -0,0 +1,12 @@
+unsigned shl_or_constant1(unsigned a)
+{
+	return (a | 0x000fffff) << 12;
+}
+
+/*
+ * check-name: shl-or-constant1
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\..*\\$0xfffff000
+ */
diff --git a/validation/optim/shl-or-constant2.c b/validation/optim/shl-or-constant2.c
new file mode 100644
index 000000000000..d4618eb1bab8
--- /dev/null
+++ b/validation/optim/shl-or-constant2.c
@@ -0,0 +1,12 @@
+unsigned shl_or_constant2(unsigned a)
+{
+	return (a | 0x00ffff0f) << 12;
+}
+
+/*
+ * check-name: shl-or-constant2
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-contains: or\\..*\\$0xfff0f
+ */
-- 
2.28.0


  parent reply	other threads:[~2020-09-06 21:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-06 21:16 [PATCH v2 0/3] fix & extend mask related testcases Luc Van Oostenryck
2020-09-06 21:16 ` [PATCH v2 1/3] optim: fix some testcases related to bitfield manipulation Luc Van Oostenryck
2020-09-06 21:16 ` Luc Van Oostenryck [this message]
2020-09-06 21:54   ` [PATCH v2 2/3] add more testcases for existing AND/OR simplifications Ramsay Jones
2020-09-07 22:28     ` Luc Van Oostenryck
2020-09-06 21:16 ` [PATCH v2 3/3] add more testcases for AND/OR simplification Luc Van Oostenryck
2020-09-07  0:15   ` Ramsay Jones
2020-09-07 22:21     ` Luc Van Oostenryck
2020-09-08 15:39       ` Ramsay Jones

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=20200906211646.58946-3-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=ramsay@ramsayjones.plus.com \
    /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).