From 37cebaabf65fe3961b9932c6582d15b3b676cefe Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Mon, 17 Jun 2019 09:43:34 +0200 Subject: 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. --- test/regression/ifconv.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/regression') 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) -- cgit