[PATCH 01/22] add testcases about OP_ADD & OP_SUB simplifications

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

 



Add some testcases about basic simplifications of additions
and subtractions.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/optim/canonical-sub-cte.c      | 10 ++++++++++
 validation/optim/reassoc-op-op1.c         | 15 +++++++++++++++
 validation/optim/simplify-add-neg.c       | 10 ++++++++++
 validation/optim/simplify-cte-sub-addl.c  | 10 ++++++++++
 validation/optim/simplify-cte-sub-addr.c  | 10 ++++++++++
 validation/optim/simplify-cte-sub-subr.c  | 10 ++++++++++
 validation/optim/simplify-neg-add.c       | 10 ++++++++++
 validation/optim/simplify-same-add-subl.c | 16 ++++++++++++++++
 validation/optim/simplify-same-add-subr.c | 16 ++++++++++++++++
 validation/optim/simplify-same-addl-sub.c | 10 ++++++++++
 validation/optim/simplify-same-sub-addl.c | 10 ++++++++++
 validation/optim/simplify-same-subl-add.c | 12 ++++++++++++
 validation/optim/simplify-same-subr-add.c | 12 ++++++++++++
 validation/optim/simplify-sub-neg.c       | 10 ++++++++++
 validation/optim/simplify-zero-sub.c      | 10 ++++++++++
 15 files changed, 171 insertions(+)
 create mode 100644 validation/optim/canonical-sub-cte.c
 create mode 100644 validation/optim/reassoc-op-op1.c
 create mode 100644 validation/optim/simplify-add-neg.c
 create mode 100644 validation/optim/simplify-cte-sub-addl.c
 create mode 100644 validation/optim/simplify-cte-sub-addr.c
 create mode 100644 validation/optim/simplify-cte-sub-subr.c
 create mode 100644 validation/optim/simplify-neg-add.c
 create mode 100644 validation/optim/simplify-same-add-subl.c
 create mode 100644 validation/optim/simplify-same-add-subr.c
 create mode 100644 validation/optim/simplify-same-addl-sub.c
 create mode 100644 validation/optim/simplify-same-sub-addl.c
 create mode 100644 validation/optim/simplify-same-subl-add.c
 create mode 100644 validation/optim/simplify-same-subr-add.c
 create mode 100644 validation/optim/simplify-sub-neg.c
 create mode 100644 validation/optim/simplify-zero-sub.c

diff --git a/validation/optim/canonical-sub-cte.c b/validation/optim/canonical-sub-cte.c
new file mode 100644
index 000000000000..223be96fa5a5
--- /dev/null
+++ b/validation/optim/canonical-sub-cte.c
@@ -0,0 +1,10 @@
+int sub_cte(int x) { return (x - 1) != (x + -1); }
+
+/*
+ * check-name: canonical-sub-cte
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\..*\\$0
+ */
diff --git a/validation/optim/reassoc-op-op1.c b/validation/optim/reassoc-op-op1.c
new file mode 100644
index 000000000000..aa7092ff57a0
--- /dev/null
+++ b/validation/optim/reassoc-op-op1.c
@@ -0,0 +1,15 @@
+int foo(int x, int *ptr)
+{
+	int t = x + 1;
+	*ptr = t;
+	return t + -1;
+}
+
+/*
+ * check-name: reassoc-op-op1
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): add\\.
+ */
diff --git a/validation/optim/simplify-add-neg.c b/validation/optim/simplify-add-neg.c
new file mode 100644
index 000000000000..19b64b096567
--- /dev/null
+++ b/validation/optim/simplify-add-neg.c
@@ -0,0 +1,10 @@
+int add_neg(int x, int y) { return x + -y; }
+
+/*
+ * check-name: simplify-add-neg
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: sub\\..*%arg1, %arg2
+ */
diff --git a/validation/optim/simplify-cte-sub-addl.c b/validation/optim/simplify-cte-sub-addl.c
new file mode 100644
index 000000000000..49e510062c03
--- /dev/null
+++ b/validation/optim/simplify-cte-sub-addl.c
@@ -0,0 +1,10 @@
+int cte_sub_addl(int x) { return (1 - x) + 1; }
+
+/*
+ * check-name: simplify-cte-sub-addl
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: sub\\..*\\$2, %arg1
+ */
diff --git a/validation/optim/simplify-cte-sub-addr.c b/validation/optim/simplify-cte-sub-addr.c
new file mode 100644
index 000000000000..81f5b34551c6
--- /dev/null
+++ b/validation/optim/simplify-cte-sub-addr.c
@@ -0,0 +1,10 @@
+int cte_sub_addr(int x) { return 2 - (x + 1); }
+
+/*
+ * check-name: simplify-cte-sub-addr
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: sub\\..*\\$1, %arg1
+ */
diff --git a/validation/optim/simplify-cte-sub-subr.c b/validation/optim/simplify-cte-sub-subr.c
new file mode 100644
index 000000000000..950b233e60c3
--- /dev/null
+++ b/validation/optim/simplify-cte-sub-subr.c
@@ -0,0 +1,10 @@
+int cte_sub_subr(int x) { return 1 - (1 - x); }
+
+/*
+ * check-name: simplify-cte-sub-subr
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\..* %arg1
+ */
diff --git a/validation/optim/simplify-neg-add.c b/validation/optim/simplify-neg-add.c
new file mode 100644
index 000000000000..66a820f28069
--- /dev/null
+++ b/validation/optim/simplify-neg-add.c
@@ -0,0 +1,10 @@
+int neg_add(int x, int y) { return -x + y; }
+
+/*
+ * check-name: simplify-neg-add
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: sub\\..*%arg2, %arg1
+ */
diff --git a/validation/optim/simplify-same-add-subl.c b/validation/optim/simplify-same-add-subl.c
new file mode 100644
index 000000000000..1f17ef0b968e
--- /dev/null
+++ b/validation/optim/simplify-same-add-subl.c
@@ -0,0 +1,16 @@
+int add_subl(int x, int y) { return (x + y) - x; }
+
+/*
+ * check-name: simplify-same-add-subl
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-start
+add_subl:
+.L0:
+	<entry-point>
+	ret.32      %arg2
+
+
+ * check-output-end
+ */
diff --git a/validation/optim/simplify-same-add-subr.c b/validation/optim/simplify-same-add-subr.c
new file mode 100644
index 000000000000..e8540703ee7d
--- /dev/null
+++ b/validation/optim/simplify-same-add-subr.c
@@ -0,0 +1,16 @@
+int add_subr(int x, int y) { return (x + y) - y; }
+
+/*
+ * check-name: simplify-same-add-subr
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-start
+add_subr:
+.L0:
+	<entry-point>
+	ret.32      %arg1
+
+
+ * check-output-end
+ */
diff --git a/validation/optim/simplify-same-addl-sub.c b/validation/optim/simplify-same-addl-sub.c
new file mode 100644
index 000000000000..51d2b07966f4
--- /dev/null
+++ b/validation/optim/simplify-same-addl-sub.c
@@ -0,0 +1,10 @@
+int foo(int x, int y) { return x + (y - x); }
+
+/*
+ * check-name: simplify-same-addl-sub
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\..*%arg2
+ */
diff --git a/validation/optim/simplify-same-sub-addl.c b/validation/optim/simplify-same-sub-addl.c
new file mode 100644
index 000000000000..78f217399e50
--- /dev/null
+++ b/validation/optim/simplify-same-sub-addl.c
@@ -0,0 +1,10 @@
+int foo(int x, int y) { return (x - y) + y; }
+
+/*
+ * check-name: simplify-same-sub-addl
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\..*%arg1
+ */
diff --git a/validation/optim/simplify-same-subl-add.c b/validation/optim/simplify-same-subl-add.c
new file mode 100644
index 000000000000..dbc0fe97f126
--- /dev/null
+++ b/validation/optim/simplify-same-subl-add.c
@@ -0,0 +1,12 @@
+int subl_add(int x, int y) { return x - (x + y); }
+
+/*
+ * check-name: simplify-same-subl-add
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: neg\\..* %arg2
+ * check-output-excludes: add\\.
+ * check-output-excludes: sub\\.
+ */
diff --git a/validation/optim/simplify-same-subr-add.c b/validation/optim/simplify-same-subr-add.c
new file mode 100644
index 000000000000..bafd2643bfd0
--- /dev/null
+++ b/validation/optim/simplify-same-subr-add.c
@@ -0,0 +1,12 @@
+int subr_add(int x, int y) { return x - (y + x); }
+
+/*
+ * check-name: simplify-same-subr-add
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: neg\\..* %arg2
+ * check-output-excludes: add\\.
+ * check-output-excludes: sub\\.
+ */
diff --git a/validation/optim/simplify-sub-neg.c b/validation/optim/simplify-sub-neg.c
new file mode 100644
index 000000000000..b6fcc2baabec
--- /dev/null
+++ b/validation/optim/simplify-sub-neg.c
@@ -0,0 +1,10 @@
+int sub_neg(int x, int y) { return x - -y; }
+
+/*
+ * check-name: simplify-sub-neg
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: add\\..*%arg., %arg.
+ */
diff --git a/validation/optim/simplify-zero-sub.c b/validation/optim/simplify-zero-sub.c
new file mode 100644
index 000000000000..cc8fe7a3159b
--- /dev/null
+++ b/validation/optim/simplify-zero-sub.c
@@ -0,0 +1,10 @@
+int zero_sub(int x) { return 0 - x; }
+
+/*
+ * check-name: simplify-zero-sub
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: neg\\..* %arg1
+ */
-- 
2.28.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