aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/optim
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-10 12:20:36 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-22 09:25:34 +0200
commit570f17482ec63344dbd20cfa83f44c38b03e6986 (patch)
tree6575a46635a9ecf1441bf7132376d4cd1f758e75 /validation/optim
parentcd554eebc1d6b10546f8478e47490737168644d7 (diff)
downloadsparse-dev-570f17482ec63344dbd20cfa83f44c38b03e6986.tar.gz
add testcases for bitfield & AND/OR simplification
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@gmail.com>
Diffstat (limited to 'validation/optim')
-rw-r--r--validation/optim/and-or-bf0.c25
-rw-r--r--validation/optim/and-or-bf1.c19
-rw-r--r--validation/optim/and-or-bf2.c28
-rw-r--r--validation/optim/and-or-bfs.c24
-rw-r--r--validation/optim/and-or-bfu.c22
-rw-r--r--validation/optim/and-or-bfx.c19
-rw-r--r--validation/optim/and-or-constant0.c13
-rw-r--r--validation/optim/and-or-constant1.c15
-rw-r--r--validation/optim/and-or-constant2.c14
-rw-r--r--validation/optim/and-or-lsr0.c13
-rw-r--r--validation/optim/and-or-lsr1.c14
-rw-r--r--validation/optim/and-or-lsr2.c14
-rw-r--r--validation/optim/and-or-lsrx.c14
-rw-r--r--validation/optim/and-or-mask0.c12
-rw-r--r--validation/optim/and-or-mask1.c14
-rw-r--r--validation/optim/and-or-mask2.c14
-rw-r--r--validation/optim/and-or-mask3s.c25
-rw-r--r--validation/optim/and-or-mask3u.c25
-rw-r--r--validation/optim/and-or-mask4.c25
-rw-r--r--validation/optim/and-or-maskx.c14
-rw-r--r--validation/optim/and-or-shl0.c13
-rw-r--r--validation/optim/and-or-shl1.c14
-rw-r--r--validation/optim/and-or-shl2.c14
-rw-r--r--validation/optim/and-or-shlx.c14
-rw-r--r--validation/optim/and-or-trunc0.c14
-rw-r--r--validation/optim/and-or-trunc1.c13
-rw-r--r--validation/optim/and-or-trunc2.c14
-rw-r--r--validation/optim/and-or-truncx.c14
-rw-r--r--validation/optim/bitfield-store-load0.c (renamed from validation/optim/store-load-bitfield.c)0
-rw-r--r--validation/optim/bitfield-store-loads.c24
-rw-r--r--validation/optim/bitfield-store-loadu.c22
-rw-r--r--validation/optim/or-and-constant1.c29
-rw-r--r--validation/optim/sh-or-and0.c21
-rw-r--r--validation/optim/sh-or-and1.c21
-rw-r--r--validation/optim/sh-or-and2.c22
-rw-r--r--validation/optim/trunc-or-shl.c13
36 files changed, 625 insertions, 0 deletions
diff --git a/validation/optim/and-or-bf0.c b/validation/optim/and-or-bf0.c
new file mode 100644
index 00000000..a17ff82d
--- /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 00000000..d20f1cb7
--- /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 00000000..cccaa85b
--- /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 00000000..e08b816e
--- /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 00000000..c9dcfc33
--- /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 00000000..ed04e2d3
--- /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 00000000..e3ff0fa4
--- /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 00000000..3f1c9052
--- /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 00000000..82e0d3c6
--- /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 00000000..227c5aed
--- /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 00000000..4806d7bc
--- /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 00000000..a0df2963
--- /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 00000000..0b7d8f44
--- /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 00000000..2d2245ea
--- /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 00000000..f86e0565
--- /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 00000000..6c340c7e
--- /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 00000000..cf264723
--- /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 00000000..c5b6c5fa
--- /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 00000000..1c4bc01a
--- /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 00000000..497c1a60
--- /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 00000000..c9914f22
--- /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 00000000..1c7b104c
--- /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 00000000..a0099325
--- /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 00000000..b6862800
--- /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 00000000..873cb2d5
--- /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 00000000..84c20317
--- /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 00000000..04cb57e7
--- /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 00000000..47d80dae
--- /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
index f68cb600..f68cb600 100644
--- a/validation/optim/store-load-bitfield.c
+++ b/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 00000000..99a0a03a
--- /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 00000000..4c289504
--- /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 00000000..aa673b90
--- /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 00000000..4a099df2
--- /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 00000000..44a07ec5
--- /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 00000000..c292057c
--- /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 00000000..70d8bd1d
--- /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
+ */