aboutsummaryrefslogtreecommitdiffstats
path: root/test/gourdinl/c/floor.c
diff options
context:
space:
mode:
authorLéo Gourdin <leo.gourdin@univ-grenoble-alpes.fr>2021-04-22 11:25:02 +0200
committerLéo Gourdin <leo.gourdin@univ-grenoble-alpes.fr>2021-04-22 11:25:02 +0200
commitdff562c47c47fcac90c116782c92b692f2bb9bf9 (patch)
tree9325a0eea680b8f7f1256cbac3f93423ef23b9e7 /test/gourdinl/c/floor.c
parente37d655db0ec3d2c002e200c3e70a1997e39a458 (diff)
downloadcompcert-kvx-dff562c47c47fcac90c116782c92b692f2bb9bf9.tar.gz
compcert-kvx-dff562c47c47fcac90c116782c92b692f2bb9bf9.zip
moving my tests
Diffstat (limited to 'test/gourdinl/c/floor.c')
-rw-r--r--test/gourdinl/c/floor.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/gourdinl/c/floor.c b/test/gourdinl/c/floor.c
new file mode 100644
index 00000000..33a57af3
--- /dev/null
+++ b/test/gourdinl/c/floor.c
@@ -0,0 +1,29 @@
+int main(int n)
+{
+ int x = 1, i;
+
+ /* for positive values */
+ if (n > 0)
+ {
+ for (; x <= n >> 1;)
+ {
+ x = x << 1;
+ }
+ n = x;
+ }
+ /* for negative values */
+ else
+ {
+ n = ~n;
+ n = n + 1;
+ for (; x <= n >> 1;)
+ {
+ x = x << 1;
+ }
+ x = x << 1;
+ x = ~x;
+ x = x + 1;
+ n = x;
+ }
+ return n;
+}