[PATCH v3 02/15] add testcases for bitfield & AND/OR simplification

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

 



The extraction & insertion of bitfields is made of relatively
complex combinations of SHL/LSR/AND/OR and TRUNC/ZEXT/SEXT.

Add a few testcases showing the effectiveness of their
simplification and to catch possible future regressions.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/optim/and-or-bf0.c                 | 25 ++++++++++++++++
 validation/optim/and-or-bf1.c                 | 19 ++++++++++++
 validation/optim/and-or-bf2.c                 | 28 ++++++++++++++++++
 validation/optim/and-or-bfs.c                 | 24 +++++++++++++++
 validation/optim/and-or-bfu.c                 | 22 ++++++++++++++
 validation/optim/and-or-bfx.c                 | 19 ++++++++++++
 validation/optim/and-or-constant0.c           | 13 +++++++++
 validation/optim/and-or-constant1.c           | 15 ++++++++++
 validation/optim/and-or-constant2.c           | 14 +++++++++
 validation/optim/and-or-lsr0.c                | 13 +++++++++
 validation/optim/and-or-lsr1.c                | 14 +++++++++
 validation/optim/and-or-lsr2.c                | 14 +++++++++
 validation/optim/and-or-lsrx.c                | 14 +++++++++
 validation/optim/and-or-mask0.c               | 12 ++++++++
 validation/optim/and-or-mask1.c               | 14 +++++++++
 validation/optim/and-or-mask2.c               | 14 +++++++++
 validation/optim/and-or-mask3s.c              | 25 ++++++++++++++++
 validation/optim/and-or-mask3u.c              | 25 ++++++++++++++++
 validation/optim/and-or-mask4.c               | 25 ++++++++++++++++
 validation/optim/and-or-maskx.c               | 14 +++++++++
 validation/optim/and-or-shl0.c                | 13 +++++++++
 validation/optim/and-or-shl1.c                | 14 +++++++++
 validation/optim/and-or-shl2.c                | 14 +++++++++
 validation/optim/and-or-shlx.c                | 14 +++++++++
 validation/optim/and-or-trunc0.c              | 14 +++++++++
 validation/optim/and-or-trunc1.c              | 13 +++++++++
 validation/optim/and-or-trunc2.c              | 14 +++++++++
 validation/optim/and-or-truncx.c              | 14 +++++++++
 ...load-bitfield.c => bitfield-store-load0.c} |  0
 validation/optim/bitfield-store-loads.c       | 24 +++++++++++++++
 validation/optim/bitfield-store-loadu.c       | 22 ++++++++++++++
 validation/optim/or-and-constant1.c           | 29 +++++++++++++++++++
 validation/optim/sh-or-and0.c                 | 21 ++++++++++++++
 validation/optim/sh-or-and1.c                 | 21 ++++++++++++++
 validation/optim/sh-or-and2.c                 | 22 ++++++++++++++
 validation/optim/trunc-or-shl.c               | 13 +++++++++
 36 files changed, 625 insertions(+)
 create mode 100644 validation/optim/and-or-bf0.c
 create mode 100644 validation/optim/and-or-bf1.c
 create mode 100644 validation/optim/and-or-bf2.c
 create mode 100644 validation/optim/and-or-bfs.c
 create mode 100644 validation/optim/and-or-bfu.c
 create mode 100644 validation/optim/and-or-bfx.c
 create mode 100644 validation/optim/and-or-constant0.c
 create mode 100644 validation/optim/and-or-constant1.c
 create mode 100644 validation/optim/and-or-constant2.c
 create mode 100644 validation/optim/and-or-lsr0.c
 create mode 100644 validation/optim/and-or-lsr1.c
 create mode 100644 validation/optim/and-or-lsr2.c
 create mode 100644 validation/optim/and-or-lsrx.c
 create mode 100644 validation/optim/and-or-mask0.c
 create mode 100644 validation/optim/and-or-mask1.c
 create mode 100644 validation/optim/and-or-mask2.c
 create mode 100644 validation/optim/and-or-mask3s.c
 create mode 100644 validation/optim/and-or-mask3u.c
 create mode 100644 validation/optim/and-or-mask4.c
 create mode 100644 validation/optim/and-or-maskx.c
 create mode 100644 validation/optim/and-or-shl0.c
 create mode 100644 validation/optim/and-or-shl1.c
 create mode 100644 validation/optim/and-or-shl2.c
 create mode 100644 validation/optim/and-or-shlx.c
 create mode 100644 validation/optim/and-or-trunc0.c
 create mode 100644 validation/optim/and-or-trunc1.c
 create mode 100644 validation/optim/and-or-trunc2.c
 create mode 100644 validation/optim/and-or-truncx.c
 rename validation/optim/{store-load-bitfield.c => bitfield-store-load0.c} (100%)
 create mode 100644 validation/optim/bitfield-store-loads.c
 create mode 100644 validation/optim/bitfield-store-loadu.c
 create mode 100644 validation/optim/or-and-constant1.c
 create mode 100644 validation/optim/sh-or-and0.c
 create mode 100644 validation/optim/sh-or-and1.c
 create mode 100644 validation/optim/sh-or-and2.c
 create mode 100644 validation/optim/trunc-or-shl.c

diff --git a/validation/optim/and-or-bf0.c b/validation/optim/and-or-bf0.c
new file mode 100644
index 000000000..a17ff82d3
--- /dev/null
+++ b/validation/optim/and-or-bf0.c
@@ -0,0 +1,25 @@
+struct s {
+	int f:3;
+};
+
+void foo(struct s *p, int a)
+{
+	p->f = 1;
+	p->f = a;
+}
+
+void bar(struct s *p, int a)
+{
+	p->f = a;
+	p->f = 1;
+}
+
+/*
+ * check-name: and-or-bf0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(3): and\\.
+ * check-output-pattern(2): or\\.
+ */
diff --git a/validation/optim/and-or-bf1.c b/validation/optim/and-or-bf1.c
new file mode 100644
index 000000000..d20f1cb7c
--- /dev/null
+++ b/validation/optim/and-or-bf1.c
@@ -0,0 +1,19 @@
+struct s {
+	int  :2;
+	int f:3;
+};
+
+void foo(struct s *d, const struct s *s, int a)
+{
+	d->f = s->f | a;
+}
+
+/*
+ * check-name: and-or-bf1
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(2): and\\.
+ * check-output-pattern(2): or\\.
+ */
diff --git a/validation/optim/and-or-bf2.c b/validation/optim/and-or-bf2.c
new file mode 100644
index 000000000..cccaa85bc
--- /dev/null
+++ b/validation/optim/and-or-bf2.c
@@ -0,0 +1,28 @@
+struct s {
+	char a:3;
+	char b:3;
+	char c:2;
+};
+
+void foo(struct s *p)
+{
+	p->a = 1;
+	p->b = 2;
+	p->c = 3;
+}
+
+/*
+ * check-name: and-or-bf2
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-start
+foo:
+.L0:
+	<entry-point>
+	store.8     $209 -> 0[%arg1]
+	ret
+
+
+ * check-output-end
+ */
diff --git a/validation/optim/and-or-bfs.c b/validation/optim/and-or-bfs.c
new file mode 100644
index 000000000..e08b816e2
--- /dev/null
+++ b/validation/optim/and-or-bfs.c
@@ -0,0 +1,24 @@
+struct s {
+	  signed int  :2;
+	  signed int f:3;
+};
+
+int bfs(struct s s, int a)
+{
+	s.f = a;
+	return s.f;
+}
+
+/*
+ * check-name: and-or-bfs
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): trunc\\.
+ * check-output-pattern(1): sext\\.
+ * check-output-excludes: and\\.
+ * check-output-excludes: or\\.
+ * check-output-excludes: shl\\.
+ * check-output-excludes: lsr\\.
+ */
diff --git a/validation/optim/and-or-bfu.c b/validation/optim/and-or-bfu.c
new file mode 100644
index 000000000..c9dcfc33e
--- /dev/null
+++ b/validation/optim/and-or-bfu.c
@@ -0,0 +1,22 @@
+struct u {
+	unsigned int  :2;
+	unsigned int f:3;
+};
+
+int bfu(struct u s, int a)
+{
+	s.f = a;
+	return s.f;
+}
+
+/*
+ * check-name: and-or-bfu
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): and\\.
+ * check-output-excludes: or\\.
+ * check-output-excludes: shl\\.
+ * check-output-excludes: lsr\\.
+ */
diff --git a/validation/optim/and-or-bfx.c b/validation/optim/and-or-bfx.c
new file mode 100644
index 000000000..ed04e2d31
--- /dev/null
+++ b/validation/optim/and-or-bfx.c
@@ -0,0 +1,19 @@
+struct s {
+	int f:3;
+};
+
+void foo(struct s *p, int a, int b)
+{
+	p->f = a;
+	p->f = b;
+}
+
+/*
+ * check-name: and-or-bfx
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(2): and\\.
+ * check-output-pattern(1): or\\.
+ */
diff --git a/validation/optim/and-or-constant0.c b/validation/optim/and-or-constant0.c
new file mode 100644
index 000000000..e3ff0fa46
--- /dev/null
+++ b/validation/optim/and-or-constant0.c
@@ -0,0 +1,13 @@
+int foo(int x)
+{
+	return (x | 0xfffff000) & 0xfff;
+}
+
+/*
+ * check-name: and-or-constant0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/and-or-constant1.c b/validation/optim/and-or-constant1.c
new file mode 100644
index 000000000..3f1c90528
--- /dev/null
+++ b/validation/optim/and-or-constant1.c
@@ -0,0 +1,15 @@
+int foo(int x)
+{
+	return (x | 0x000fffff) & 0xfff;
+}
+
+/*
+ * check-name: or-and-constant1
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\..*\\$0xfff
+ * check-output-excludes: and\\.
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/and-or-constant2.c b/validation/optim/and-or-constant2.c
new file mode 100644
index 000000000..82e0d3c69
--- /dev/null
+++ b/validation/optim/and-or-constant2.c
@@ -0,0 +1,14 @@
+int foo(int x)
+{
+	return (x | 0xfffffff0) & 0xfff;
+}
+
+/*
+ * check-name: and-or-constant2
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: or\\..*\\$0xff0
+ * check-output-excludes: or\\..*\\$0xfffffff0
+ */
diff --git a/validation/optim/and-or-lsr0.c b/validation/optim/and-or-lsr0.c
new file mode 100644
index 000000000..227c5aede
--- /dev/null
+++ b/validation/optim/and-or-lsr0.c
@@ -0,0 +1,13 @@
+int foo(int a, int b)
+{
+	return ((a & 0x00000fff) | b) >> 12;
+}
+
+/*
+ * check-name: and-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/and-or-lsr1.c b/validation/optim/and-or-lsr1.c
new file mode 100644
index 000000000..4806d7bca
--- /dev/null
+++ b/validation/optim/and-or-lsr1.c
@@ -0,0 +1,14 @@
+int foo(int a, int b)
+{
+	return ((a & 0xfffff000) | b) >> 12;
+}
+
+/*
+ * check-name: and-or-lsr1
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(0): and\\.
+ * check-output-pattern(1): or\\.
+ */
diff --git a/validation/optim/and-or-lsr2.c b/validation/optim/and-or-lsr2.c
new file mode 100644
index 000000000..a0df29631
--- /dev/null
+++ b/validation/optim/and-or-lsr2.c
@@ -0,0 +1,14 @@
+int foo(int x, int y)
+{
+	return ((x & 0xf0ffffff) | y) >> 12;
+}
+
+/*
+ * check-name: and-or-lsr2
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: and\\..*\\$0xf0fff
+ * check-output-excludes: and\\..*\\$0xf0ffffff
+ */
diff --git a/validation/optim/and-or-lsrx.c b/validation/optim/and-or-lsrx.c
new file mode 100644
index 000000000..0b7d8f445
--- /dev/null
+++ b/validation/optim/and-or-lsrx.c
@@ -0,0 +1,14 @@
+unsigned int foo(unsigned int x, unsigned int y, unsigned int a)
+{
+	return ((x & y) | (a & 0x0fff)) >> 12;
+}
+
+/*
+ * check-name: and-or-lsrx
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): and\\.
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/and-or-mask0.c b/validation/optim/and-or-mask0.c
new file mode 100644
index 000000000..2d2245ea5
--- /dev/null
+++ b/validation/optim/and-or-mask0.c
@@ -0,0 +1,12 @@
+int foo(int a, int b)
+{
+	return ((a & 0xfffff000) | b) & 0xfff;
+}
+
+/*
+ * check-name: and-or-mask0
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/and-or-mask1.c b/validation/optim/and-or-mask1.c
new file mode 100644
index 000000000..f86e05659
--- /dev/null
+++ b/validation/optim/and-or-mask1.c
@@ -0,0 +1,14 @@
+int foo(int a, int b)
+{
+	return ((a & 0x0fffffff) | b) & 0xfff;
+}
+
+/*
+ * check-name: and-or-mask1
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): and\\.
+ * check-output-pattern(1): or\\.
+ */
diff --git a/validation/optim/and-or-mask2.c b/validation/optim/and-or-mask2.c
new file mode 100644
index 000000000..6c340c7ee
--- /dev/null
+++ b/validation/optim/and-or-mask2.c
@@ -0,0 +1,14 @@
+int foo(int x, int y)
+{
+	return ((x & 0xffffff0f) | y) & 0xfff;
+}
+
+/*
+ * check-name: and-or-mask2
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: and\\..*\\$0xf0f
+ * check-output-excludes: and\\..*\\$0xffffff0f
+ */
diff --git a/validation/optim/and-or-mask3s.c b/validation/optim/and-or-mask3s.c
new file mode 100644
index 000000000..cf2647233
--- /dev/null
+++ b/validation/optim/and-or-mask3s.c
@@ -0,0 +1,25 @@
+#define W	3
+#define	S	8
+#define M	(W << S)
+
+static inline int fun(unsigned int x, unsigned int y)
+{
+	return ((x & M) | (y << S)) >> S;
+}
+
+short foo(unsigned int x, unsigned int y)
+{
+	return fun(x, y) & W;
+}
+
+/*
+ * check-name: and-or-mask3s
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): lsr\\.
+ * check-output-pattern(1): or\\.
+ * check-output-pattern(1): and\\.
+ * check-output-excludes: shl\\.
+ */
diff --git a/validation/optim/and-or-mask3u.c b/validation/optim/and-or-mask3u.c
new file mode 100644
index 000000000..c5b6c5fa0
--- /dev/null
+++ b/validation/optim/and-or-mask3u.c
@@ -0,0 +1,25 @@
+#define W	3
+#define	S	8
+#define M	(W << S)
+
+static inline int fun(unsigned int x, unsigned int y)
+{
+	return ((x & M) | (y << S)) >> S;
+}
+
+int foo(unsigned int x, unsigned int y)
+{
+	return fun(x, y) & W;
+}
+
+/*
+ * check-name: and-or-mask3u
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): lsr\\.
+ * check-output-pattern(1): or\\.
+ * check-output-pattern(1): and\\.
+ * check-output-excludes: shl\\.
+ */
diff --git a/validation/optim/and-or-mask4.c b/validation/optim/and-or-mask4.c
new file mode 100644
index 000000000..1c4bc01a8
--- /dev/null
+++ b/validation/optim/and-or-mask4.c
@@ -0,0 +1,25 @@
+#define W	3
+#define	S	8
+#define M	(W << S)
+
+static inline int fun(unsigned int x, unsigned int y)
+{
+	return ((x & W) | (y >> S)) << S;
+}
+
+int foo(unsigned int x, unsigned int y)
+{
+	return fun(x, y) & M;
+}
+
+/*
+ * check-name: and-or-mask4
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): shl\\.
+ * check-output-pattern(1): or\\.
+ * check-output-pattern(1): and\\.
+ * check-output-excludes: lsr\\.
+ */
diff --git a/validation/optim/and-or-maskx.c b/validation/optim/and-or-maskx.c
new file mode 100644
index 000000000..497c1a60e
--- /dev/null
+++ b/validation/optim/and-or-maskx.c
@@ -0,0 +1,14 @@
+int foo(int x, int y, int a)
+{
+	return ((x & y) | (a & 0xf000)) & 0x0fff;
+}
+
+/*
+ * check-name: and-or-maskx
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(2): and\\.
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/and-or-shl0.c b/validation/optim/and-or-shl0.c
new file mode 100644
index 000000000..c9914f22c
--- /dev/null
+++ b/validation/optim/and-or-shl0.c
@@ -0,0 +1,13 @@
+int foo(int a, int b)
+{
+	return ((a & 0xfff00000) | b) << 12;
+}
+
+/*
+ * check-name: and-or-shl0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/and-or-shl1.c b/validation/optim/and-or-shl1.c
new file mode 100644
index 000000000..1c7b104cf
--- /dev/null
+++ b/validation/optim/and-or-shl1.c
@@ -0,0 +1,14 @@
+int foo(int a, int b)
+{
+	return ((a & 0x000fffff) | b) << 12;
+}
+
+/*
+ * check-name: and-or-shl1
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(0): and\\.
+ * check-output-pattern(1): or\\.
+ */
diff --git a/validation/optim/and-or-shl2.c b/validation/optim/and-or-shl2.c
new file mode 100644
index 000000000..a00993255
--- /dev/null
+++ b/validation/optim/and-or-shl2.c
@@ -0,0 +1,14 @@
+int foo(int x, int y)
+{
+	return ((x & 0xffffff0f) | y) << 12;
+}
+
+/*
+ * check-name: and-or-shl2
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: and\\..*\\$0xfff0f
+ * check-output-excludes: and\\..*\\$0xffffff0f
+ */
diff --git a/validation/optim/and-or-shlx.c b/validation/optim/and-or-shlx.c
new file mode 100644
index 000000000..b68628006
--- /dev/null
+++ b/validation/optim/and-or-shlx.c
@@ -0,0 +1,14 @@
+unsigned int foo(unsigned int x, unsigned int y, unsigned int a)
+{
+	return ((x & y) | (a & 0xfff00000)) << 12;
+}
+
+/*
+ * check-name: and-or-shlx
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): and\\.
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/and-or-trunc0.c b/validation/optim/and-or-trunc0.c
new file mode 100644
index 000000000..873cb2d5e
--- /dev/null
+++ b/validation/optim/and-or-trunc0.c
@@ -0,0 +1,14 @@
+char foo(int x, int y)
+{
+	return (x & 0xff00) | y;
+}
+
+/*
+ * check-name: and-or-trunc0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: and\\.
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/and-or-trunc1.c b/validation/optim/and-or-trunc1.c
new file mode 100644
index 000000000..84c20317d
--- /dev/null
+++ b/validation/optim/and-or-trunc1.c
@@ -0,0 +1,13 @@
+char foo(int x, int y)
+{
+	return (x & 0xffff) | y;
+}
+
+/*
+ * check-name: and-or-trunc1
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: and\\.
+ */
diff --git a/validation/optim/and-or-trunc2.c b/validation/optim/and-or-trunc2.c
new file mode 100644
index 000000000..04cb57e79
--- /dev/null
+++ b/validation/optim/and-or-trunc2.c
@@ -0,0 +1,14 @@
+char foo(int x, int y)
+{
+	return (x & 0xff07) | y;
+}
+
+/*
+ * check-name: and-or-trunc2
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): and\\.
+ * check-output-pattern(1): and\\..*\\$7
+ */
diff --git a/validation/optim/and-or-truncx.c b/validation/optim/and-or-truncx.c
new file mode 100644
index 000000000..47d80daec
--- /dev/null
+++ b/validation/optim/and-or-truncx.c
@@ -0,0 +1,14 @@
+char foo(int x, int y, int b)
+{
+	return (x & y) | (b & 0xff00);
+}
+
+/*
+ * check-name: and-or-truncx
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): and\\.
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/store-load-bitfield.c b/validation/optim/bitfield-store-load0.c
similarity index 100%
rename from validation/optim/store-load-bitfield.c
rename to validation/optim/bitfield-store-load0.c
diff --git a/validation/optim/bitfield-store-loads.c b/validation/optim/bitfield-store-loads.c
new file mode 100644
index 000000000..99a0a03a7
--- /dev/null
+++ b/validation/optim/bitfield-store-loads.c
@@ -0,0 +1,24 @@
+struct s {
+	char :2;
+	char f:3;
+};
+
+int foo(struct s s, int a)
+{
+	s.f = a;
+	return s.f;
+}
+
+/*
+ * check-name: bitfield-store-load signed
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: shl\\.
+ * check-output-excludes: lsr\\.
+ * check-output-excludes: or\\.
+ * check-output-excludes: [sz]ext\\.
+ * check-output-excludes: trunc\\.
+ * check-output-pattern(1): and\\.
+ */
diff --git a/validation/optim/bitfield-store-loadu.c b/validation/optim/bitfield-store-loadu.c
new file mode 100644
index 000000000..4c289504c
--- /dev/null
+++ b/validation/optim/bitfield-store-loadu.c
@@ -0,0 +1,22 @@
+struct s {
+	unsigned int :2;
+	unsigned int f:3;
+};
+
+int foo(struct s s, int a)
+{
+	s.f = a;
+	return s.f;
+}
+
+/*
+ * check-name: bitfield-store-load unsigned
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: shl\\.
+ * check-output-excludes: lsr\\.
+ * check-output-excludes: or\\.
+ * check-output-pattern(1): and\\.
+ */
diff --git a/validation/optim/or-and-constant1.c b/validation/optim/or-and-constant1.c
new file mode 100644
index 000000000..aa673b905
--- /dev/null
+++ b/validation/optim/or-and-constant1.c
@@ -0,0 +1,29 @@
+unsigned int and_or_equ(unsigned int a)
+{
+	return (a | 3) & 3;
+}
+
+int and_or_eqs(int a)
+{
+	return (a | 3) & 3;
+}
+
+unsigned int or_and_equ(unsigned int a)
+{
+	return (a & 3) | 3;
+}
+
+int or_and_eqs(int a)
+{
+	return (a & 3) | 3;
+}
+
+/*
+ * check-name: or-and-constant1
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(4): ret\\..*\\$3
+ * check-output-excludes: or\\.
+ */
diff --git a/validation/optim/sh-or-and0.c b/validation/optim/sh-or-and0.c
new file mode 100644
index 000000000..4a099df2d
--- /dev/null
+++ b/validation/optim/sh-or-and0.c
@@ -0,0 +1,21 @@
+unsigned lsr_or_and0(unsigned x, unsigned b)
+{
+	return (((x & 0x00000fff) | b) >> 12);
+}
+
+unsigned shl_or_and0(unsigned x, unsigned b)
+{
+	return (((x & 0xfff00000) | b) << 12);
+}
+
+/*
+ * check-name: sh-or-and0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): lsr\\.
+ * check-output-pattern(1): shl\\.
+ * check-output-excludes: or\\.
+ * check-output-excludes: and\\.
+ */
diff --git a/validation/optim/sh-or-and1.c b/validation/optim/sh-or-and1.c
new file mode 100644
index 000000000..44a07ec51
--- /dev/null
+++ b/validation/optim/sh-or-and1.c
@@ -0,0 +1,21 @@
+unsigned lsr_or_and1(unsigned x, unsigned b)
+{
+	return (((x & 0xfffff000) | b) >> 12);
+}
+
+unsigned shl_or_and1(unsigned x, unsigned b)
+{
+	return (((x & 0x000fffff) | b) << 12);
+}
+
+/*
+ * check-name: sh-or-and1
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): lsr\\.
+ * check-output-pattern(1): shl\\.
+ * check-output-pattern(2): or\\.
+ * check-output-excludes: and\\.
+ */
diff --git a/validation/optim/sh-or-and2.c b/validation/optim/sh-or-and2.c
new file mode 100644
index 000000000..c292057c4
--- /dev/null
+++ b/validation/optim/sh-or-and2.c
@@ -0,0 +1,22 @@
+unsigned lsr_or_and2(unsigned x, unsigned b)
+{
+	return (((x & 0xf0ffffff) | b) >> 12);
+}
+
+unsigned shl_or_and2(unsigned x, unsigned b)
+{
+	return (((x & 0xffffff0f) | b) << 12);
+}
+
+/*
+ * check-name: sh-or-and2
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): lsr\\.
+ * check-output-pattern(1): shl\\.
+ * check-output-pattern(2): or\\.
+ * check-output-pattern(1): and\\..*\\$0xf0fff000
+ * check-output-pattern(1): and\\..*\\$0xfff0f
+ */
diff --git a/validation/optim/trunc-or-shl.c b/validation/optim/trunc-or-shl.c
new file mode 100644
index 000000000..70d8bd1de
--- /dev/null
+++ b/validation/optim/trunc-or-shl.c
@@ -0,0 +1,13 @@
+char foo(int a, int b)
+{
+	return (a << 8) | b;
+}
+
+/*
+ * check-name: trunc-or-shl
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\..*%arg2
+ */
-- 
2.18.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