aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@college-de-france.fr>2019-06-17 09:43:34 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2019-06-17 13:58:35 +0200
commit37cebaabf65fe3961b9932c6582d15b3b676cefe (patch)
treeb96ff1252181269ba5ae8fdad3cea9784c571b52 /test/regression
parentddb2c968e6c57d2117434f169471d87f643d831a (diff)
downloadcompcert-kvx-37cebaabf65fe3961b9932c6582d15b3b676cefe.tar.gz
compcert-kvx-37cebaabf65fe3961b9932c6582d15b3b676cefe.zip
Perform constant propagation and strength reduction on conditional moves
A conditional move whose condition is statically known becomes a regular move. Otherwise, the condition can sometimes be simplified by strength reduction.
Diffstat (limited to 'test/regression')
-rw-r--r--test/regression/ifconv.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/regression/ifconv.c b/test/regression/ifconv.c
index dcbf43e5..e12a394c 100644
--- a/test/regression/ifconv.c
+++ b/test/regression/ifconv.c
@@ -83,6 +83,26 @@ float sdoz(float x, float y)
return x >= y ? x - y : 0.0f;
}
+/* Examples where constant propagation should take place */
+
+int constprop1(int x)
+{
+ int n = 0;
+ return n ? x : 42;
+}
+
+int constprop2(int x)
+{
+ int n = 1;
+ return n ? x : 42;
+}
+
+int constprop3(int x, int y)
+{
+ int n = 0;
+ return x < n ? y - 1 : y + 1;
+}
+
/* Test harness */
#define TESTI(call) printf(#call " = %d\n", call)