diff mbox series

[1/3] add testcases for simplification of casts.

Message ID 20210418115635.40608-2-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series remove early simplification of casts during evaluation | expand

Commit Message

Luc Van Oostenryck April 18, 2021, 11:56 a.m. UTC
and remove one that didn't made much sense.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 validation/eval/not-cast-bool.c  | 15 +++++++++++++++
 validation/eval/not-cast-float.c | 15 +++++++++++++++
 validation/optim/and-extendx.c   | 24 ------------------------
 validation/optim/trunc-not0.c    | 21 +++++++++++++++++++++
 4 files changed, 51 insertions(+), 24 deletions(-)
 create mode 100644 validation/eval/not-cast-bool.c
 create mode 100644 validation/eval/not-cast-float.c
 delete mode 100644 validation/optim/and-extendx.c
 create mode 100644 validation/optim/trunc-not0.c
diff mbox series

Patch

diff --git a/validation/eval/not-cast-bool.c b/validation/eval/not-cast-bool.c
new file mode 100644
index 000000000000..af4224125c34
--- /dev/null
+++ b/validation/eval/not-cast-bool.c
@@ -0,0 +1,15 @@ 
+static _Bool foo(void)
+{
+	unsigned char c = 1;
+	_Bool b = ~c;
+	return b;
+}
+
+/*
+ * check-name: not-cast-bool
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/eval/not-cast-float.c b/validation/eval/not-cast-float.c
new file mode 100644
index 000000000000..445b91d7563e
--- /dev/null
+++ b/validation/eval/not-cast-float.c
@@ -0,0 +1,15 @@ 
+static int foo(void)
+{
+	int i = 123;
+	float x = ~i;
+	return (x < 0);
+}
+
+/*
+ * check-name: eval-bool-zext-neg
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
diff --git a/validation/optim/and-extendx.c b/validation/optim/and-extendx.c
deleted file mode 100644
index 5c181c93384e..000000000000
--- a/validation/optim/and-extendx.c
+++ /dev/null
@@ -1,24 +0,0 @@ 
-typedef unsigned short u16;
-typedef          short s16;
-typedef unsigned   int u32;
-typedef            int s32;
-typedef unsigned  long long u64;
-typedef           long long s64;
-
-u64 ufoo(int x)
-{
-	return x & 0x7fff;
-}
-
-u64 sfoo(int x)
-{
-	return x & 0x7fff;
-}
-
-/*
- * check-name: and-extend
- * check-command: test-linearize -Wno-decl $file
- *
- * check-output-ignore
- * check-output-contains: and\\.64.*0x7fff
- */
diff --git a/validation/optim/trunc-not0.c b/validation/optim/trunc-not0.c
new file mode 100644
index 000000000000..febed165b0c4
--- /dev/null
+++ b/validation/optim/trunc-not0.c
@@ -0,0 +1,21 @@ 
+typedef __INT32_TYPE__ int32;
+typedef __INT64_TYPE__ int64;
+
+static _Bool sfoo(int64 a) { return ((int32) ~a) == (~ (int32)a); }
+static _Bool sbar(int64 a) { return (~(int32) ~a) == (int32)a; }
+
+
+typedef __UINT32_TYPE__ uint32;
+typedef __UINT64_TYPE__ uint64;
+
+static _Bool ufoo(uint64 a) { return ((uint32) ~a) == (~ (uint32)a); }
+static _Bool ubar(uint64 a) { return (~(uint32) ~a) == (uint32)a; }
+
+/*
+ * check-name: trunc-not0
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */