From 467fce3048571227e49beee068f783fb1c76a1e7 Mon Sep 17 00:00:00 2001
From: Luc Van Oostenryck
Date: Sat, 31 Oct 2020 17:20:36 +0100
Subject: simplify SEL(x == y, x, y) and friends
If the condition of a select instruction is a equality test of the
select's operands, then the result of the select is always the same as
its second operand. Same for the first operand with an inequality test.
Simplify away these selects.
Signed-off-by: Luc Van Oostenryck
---
validation/optim/eqne-select.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
create mode 100644 validation/optim/eqne-select.c
(limited to 'validation')
diff --git a/validation/optim/eqne-select.c b/validation/optim/eqne-select.c
new file mode 100644
index 00000000..9dfd88b5
--- /dev/null
+++ b/validation/optim/eqne-select.c
@@ -0,0 +1,12 @@
+int sel_eq01(int a, int b) { return ((a == b) ? a : b) == b; }
+int sel_eq10(int a, int b) { return ((a == b) ? b : a) == a; }
+int sel_ne01(int a, int b) { return ((a != b) ? a : b) == a; }
+int sel_ne10(int a, int b) { return ((a != b) ? b : a) == b; }
+
+/*
+ * check-name: eqne-select
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-returns: 1
+ */
--
cgit 1.2.3-korg