From fe9dbeb3d0ab6b12448e0eed96df1b8499d91c3c Mon Sep 17 00:00:00 2001
From: Luc Van Oostenryck
Date: Thu, 26 Nov 2020 21:11:07 +0100
Subject: fix trivial_phi() when the target is before the single value
A phi-node is called 'trivial' if it only reference itself and a
single other value. In this case the only possible value for the
phi-node is this single other value which can thus replace the
phi-node.
However, the current code get this slightly wrong when the first
referenced value is itself and not the other value.
Fix this by moving up the test checking if it references itself.
Signed-off-by: Luc Van Oostenryck
---
validation/optim/trivial-phi01.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 validation/optim/trivial-phi01.c
(limited to 'validation')
diff --git a/validation/optim/trivial-phi01.c b/validation/optim/trivial-phi01.c
new file mode 100644
index 00000000..40bd343b
--- /dev/null
+++ b/validation/optim/trivial-phi01.c
@@ -0,0 +1,20 @@
+void foo(int a)
+{
+ if (a) {
+ while (a) {
+ switch (0) {
+ default:
+ a = 0;
+ case 0:;
+ }
+ }
+ }
+}
+
+/*
+ * check-name: trivial-phi01
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-excludes: phi\\.
+ */
--
cgit 1.2.3-korg