From b2e35bf85d1d1db02aa7f74ee45a47f79463d99f Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Tue, 26 Mar 2019 21:00:36 +0100 Subject: ternary transfo --- test/monniaux/bitsliced-aes/bs.c | 13 ++++++++++++- test/monniaux/bitsliced-aes/notes.txt | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 test/monniaux/bitsliced-aes/notes.txt (limited to 'test/monniaux/bitsliced-aes') diff --git a/test/monniaux/bitsliced-aes/bs.c b/test/monniaux/bitsliced-aes/bs.c index df5c1f6b..3fc2ff8f 100644 --- a/test/monniaux/bitsliced-aes/bs.c +++ b/test/monniaux/bitsliced-aes/bs.c @@ -2,6 +2,17 @@ #include #include "bs.h" +word_t compcert_ternary(word_t x, word_t v0, word_t v1) { + return (((-(x==0)) & v0) | ((-(x!=0)) & v1)); +} + +/* Original + #define TERNARY0(cmp,v1) ((cmp) ? (v1) : 0) */ +#define TERNARY0(cmp,v1) (-(cmp != 0) & (v1)) +/* +#define TERNARY0(cmp,v1) compcert_ternary(cmp, 0, v1) +*/ + #if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) ||\ defined(__amd64__) || defined(__amd32__)|| defined(__amd16__) #define bs2le(x) (x) @@ -392,7 +403,7 @@ void bs_transpose_dst(word_t * transpose, word_t * blocks) for(j=0; j < WORD_SIZE; j++) { // TODO make const time - transpose[offset + j] |= (w & (ONE << j)) ? bitpos : 0; + transpose[offset + j] |= TERNARY0((w & (ONE << j)), bitpos); } #else diff --git a/test/monniaux/bitsliced-aes/notes.txt b/test/monniaux/bitsliced-aes/notes.txt new file mode 100644 index 00000000..954809cc --- /dev/null +++ b/test/monniaux/bitsliced-aes/notes.txt @@ -0,0 +1,25 @@ +* original +==> test.ccomp.host.out <== +cycles: 3080223 + +==> test.ccomp.k1c.out <== +cycles: 10145951 + +==> test.gcc.host.out <== +cycles: 1485887 + +==> test.gcc.k1c.out <== +cycles: 4078535 + +* neg and +==> test.ccomp.host.out <== +cycles: 2905049 + +==> test.ccomp.k1c.out <== +cycles: 7995063 + +==> test.gcc.host.out <== +cycles: 1858263 + +==> test.gcc.k1c.out <== +cycles: 5255763 -- cgit