diff options
author | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2019-06-17 09:43:34 +0200 |
---|---|---|
committer | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2019-06-17 13:58:35 +0200 |
commit | 37cebaabf65fe3961b9932c6582d15b3b676cefe (patch) | |
tree | b96ff1252181269ba5ae8fdad3cea9784c571b52 /test/regression/ifconv.c | |
parent | ddb2c968e6c57d2117434f169471d87f643d831a (diff) | |
download | compcert-37cebaabf65fe3961b9932c6582d15b3b676cefe.tar.gz compcert-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/ifconv.c')
-rw-r--r-- | test/regression/ifconv.c | 20 |
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) |