aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/optim
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-11-24 01:04:35 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-11-24 01:04:35 +0100
commit540c2c4bf47f0c517c042ff689679b2900bb36a5 (patch)
tree33b811aec1bc81b1056f66dd91d7971adb16c2b5 /validation/optim
parent4f10206cc4dcbe28d712a82497fc582585d4d2c7 (diff)
parent7f03e99c7e74d9971460e42a2230de66ae6ffdcf (diff)
downloadsparse-dev-540c2c4bf47f0c517c042ff689679b2900bb36a5.tar.gz
Merge branch 'optim-not' into next
* put PSEUDO_ARGS and PSEUDO_REGs in canonical order too * simplify (~x {&,|,^} x) --> {0,~0,~0} * simplify ((x cmp y) {&,|,^} (x !cmp y)) --> {0,1,1}
Diffstat (limited to 'validation/optim')
-rw-r--r--validation/optim/canonical-arg.c20
-rw-r--r--validation/optim/canonical-not.c9
-rw-r--r--validation/optim/cse-arg01.c9
-rw-r--r--validation/optim/cse-not01.c11
-rw-r--r--validation/optim/cse-not02.c11
-rw-r--r--validation/optim/cse-reg01.c9
6 files changed, 69 insertions, 0 deletions
diff --git a/validation/optim/canonical-arg.c b/validation/optim/canonical-arg.c
new file mode 100644
index 00000000..a8ecc9bd
--- /dev/null
+++ b/validation/optim/canonical-arg.c
@@ -0,0 +1,20 @@
+int def(void);
+
+int canon_arg_arg(int a, int b)
+{
+ return (a + b) == (b + a);
+}
+
+int canon_arg_reg(int a)
+{
+ int b = def();
+ return (a + b) == (b + a);
+}
+
+/*
+ * check-name: canonical-arg
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/canonical-not.c b/validation/optim/canonical-not.c
new file mode 100644
index 00000000..9698590f
--- /dev/null
+++ b/validation/optim/canonical-not.c
@@ -0,0 +1,9 @@
+int canon_not(int a, int b) { return (a & ~b) == (~b & a); }
+
+/*
+ * check-name: canonical-not
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/cse-arg01.c b/validation/optim/cse-arg01.c
new file mode 100644
index 00000000..3e3e141a
--- /dev/null
+++ b/validation/optim/cse-arg01.c
@@ -0,0 +1,9 @@
+int foo(int a, int b) { return (a < b) == (b > a); }
+
+/*
+ * check-name: cse-arg01
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/cse-not01.c b/validation/optim/cse-not01.c
new file mode 100644
index 00000000..ea1bb7cf
--- /dev/null
+++ b/validation/optim/cse-not01.c
@@ -0,0 +1,11 @@
+int and(int a) { return (~a & a) == 0; }
+int ior(int a) { return (~a | a) == ~0; }
+int xor(int a) { return (~a ^ a) == ~0; }
+
+/*
+ * check-name: cse-not01
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/cse-not02.c b/validation/optim/cse-not02.c
new file mode 100644
index 00000000..70addebc
--- /dev/null
+++ b/validation/optim/cse-not02.c
@@ -0,0 +1,11 @@
+int and(int a, int b) { return ((a == b) & (a != b)) == 0; }
+int ior(int a, int b) { return ((a == b) | (a != b)) == 1; }
+int xor(int a, int b) { return ((a == b) ^ (a != b)) == 1; }
+
+/*
+ * check-name: cse-not02
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/cse-reg01.c b/validation/optim/cse-reg01.c
new file mode 100644
index 00000000..3ea283d3
--- /dev/null
+++ b/validation/optim/cse-reg01.c
@@ -0,0 +1,9 @@
+int foo(int a, int b) { int x = a + b, y = ~b; return (x < y) == (y > x); }
+
+/*
+ * check-name: cse-reg01
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */