aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2021-02-02 17:01:25 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2021-02-02 17:01:25 +0100
commit7d60eca51d9f1815834a132eb634b251bdfb6e6b (patch)
tree45db715cdb63ce5c1ebef3751bebd1a2d184b362
parent11018c3d46845722daf73883ce3959afdd6ac92f (diff)
downloadcompcert-kvx-7d60eca51d9f1815834a132eb634b251bdfb6e6b.tar.gz
compcert-kvx-7d60eca51d9f1815834a132eb634b251bdfb6e6b.zip
example of cmov
-rw-r--r--test/monniaux/cmov/cmov2.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/monniaux/cmov/cmov2.c b/test/monniaux/cmov/cmov2.c
new file mode 100644
index 00000000..6ecab61b
--- /dev/null
+++ b/test/monniaux/cmov/cmov2.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+
+long cmovl(int x, long y, long z) {
+ return x ? y : z;
+}
+
+int cmovi(int x, int y, int z) {
+ return x ? y : z;
+}
+
+double cmovd(int x, double y, double z) {
+ return x ? y : z;
+}
+
+float cmovf(int x, float y, float z) {
+ return x ? y : z;
+}
+
+int main() {
+ printf("%ld\n", cmovl(1, 42, 65));
+ printf("%ld\n", cmovl(0, 42, 65));
+ printf("%d\n", cmovi(1, 42, 65));
+ printf("%d\n", cmovi(0, 42, 65));
+ printf("%f\n", cmovd(1, 42., 65.));
+ printf("%f\n", cmovd(0, 42., 65.));
+ printf("%f\n", cmovf(1, 42.f, 65.f));
+ printf("%f\n", cmovf(0, 42.f, 65.f));
+}