new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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\\.
+ */
new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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
+ */
new file mode 100644
@@ -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\\.
+ */
new file mode 100644
@@ -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\\.
+ */
new file mode 100644
@@ -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.
+ */
new file mode 100644
@@ -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
+ */
Add some testcases about basic simplifications of additions and subtractions. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- 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