aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2021-02-02 13:07:56 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2021-02-02 13:07:56 +0100
commit7afc85c95aaec5cc0935733cac487e13f114cc46 (patch)
tree7570beb0341a7bf2f2ecf923848552a7d8bfc3e3 /test
parent5afebe369cea7f2746dec7c64514822562e9100e (diff)
downloadcompcert-kvx-7afc85c95aaec5cc0935733cac487e13f114cc46.tar.gz
compcert-kvx-7afc85c95aaec5cc0935733cac487e13f114cc46.zip
cmov on integers
Diffstat (limited to 'test')
-rw-r--r--test/monniaux/cmov/cmov.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/monniaux/cmov/cmov.c b/test/monniaux/cmov/cmov.c
new file mode 100644
index 00000000..2e388834
--- /dev/null
+++ b/test/monniaux/cmov/cmov.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+long cmovl(int x, long y, long z) {
+ return __builtin_sel(x, y, z);
+}
+
+int cmovi(int x, int y, int z) {
+ return __builtin_sel(x, y, z);
+}
+
+double cmovd(int x, double y, double z) {
+ return __builtin_sel(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.));
+}