diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-03-24 18:10:43 +0100 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-03-24 18:10:43 +0100 |
commit | cc65063de9adb38f9e3d5ccc8a85135ae269124b (patch) | |
tree | b33bb19c5ea43c7e35b71663f77170a8a65d5038 /test/monniaux | |
parent | 52aeb8026a9d9d2675eebf965d4ff3f87a0e2346 (diff) | |
download | compcert-kvx-cc65063de9adb38f9e3d5ccc8a85135ae269124b.tar.gz compcert-kvx-cc65063de9adb38f9e3d5ccc8a85135ae269124b.zip |
another ternary implementation
Diffstat (limited to 'test/monniaux')
-rw-r--r-- | test/monniaux/ternary/ternary.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/test/monniaux/ternary/ternary.c b/test/monniaux/ternary/ternary.c index 45201ff8..79025639 100644 --- a/test/monniaux/ternary/ternary.c +++ b/test/monniaux/ternary/ternary.c @@ -5,10 +5,16 @@ typedef uint32_t data; +#if 0 +#define TERNARY(a, b, c) ((a) ? (b) : (c)) +#else +#define TERNARY(a, b, c) (((-(a)) & (b)) | ((-1+(a)) & (c))) +#endif + data silly_computation(void) { data x = 1; for(int i=0; i<10000; i++) { - x = x * (((x & 0x100) != 0) ? 45561U : 337777U); + x = x * TERNARY(((x & 0x100) != 0), 45561U, 337777U); } return x; } |