diff mbox series

[1/2] eval_insn: add testcases for incorrect type in OP_SET_*

Message ID 20201029225905.85037-2-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series give an explicit type to operands of comparisons | expand

Commit Message

Luc Van Oostenryck Oct. 29, 2020, 10:59 p.m. UTC
Because of the lack of type information, compare instruction are
not always handled correctly. So, add some testcases for this.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 validation/optim/cmp-op-type.c | 18 ++++++++++++++++++
 validation/optim/cmp-type0.c   | 13 +++++++++++++
 validation/optim/cmp-type1.c   | 16 ++++++++++++++++
 3 files changed, 47 insertions(+)
 create mode 100644 validation/optim/cmp-op-type.c
 create mode 100644 validation/optim/cmp-type0.c
 create mode 100644 validation/optim/cmp-type1.c
diff mbox series

Patch

diff --git a/validation/optim/cmp-op-type.c b/validation/optim/cmp-op-type.c
new file mode 100644
index 000000000000..037272f84465
--- /dev/null
+++ b/validation/optim/cmp-op-type.c
@@ -0,0 +1,18 @@ 
+extern int get(void);
+
+static int array[8192];
+
+static int foo(void)
+{
+	int n = -1;
+	if (n < 0)
+		n = get();
+	return array[n];
+}
+
+/*
+ * check-name: cmp-op-type
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ */
diff --git a/validation/optim/cmp-type0.c b/validation/optim/cmp-type0.c
new file mode 100644
index 000000000000..695d082b6aed
--- /dev/null
+++ b/validation/optim/cmp-type0.c
@@ -0,0 +1,13 @@ 
+static int foo(long long a)
+{
+	return 0LL < (0x80000000LL + (a - a));
+}
+
+/*
+ * check-name: cmp-type0
+ * check-command: test-linearize $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: ret.*\\$1
+ */
diff --git a/validation/optim/cmp-type1.c b/validation/optim/cmp-type1.c
new file mode 100644
index 000000000000..2fb78a0bb86a
--- /dev/null
+++ b/validation/optim/cmp-type1.c
@@ -0,0 +1,16 @@ 
+int foo(void)
+{
+	int r;
+	long n;
+	n = 0;
+	return n < 2147483648U;
+}
+
+/*
+ * check-name: cmp-type1
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\..*\\$1
+ */