From b8b9cd5066b43fea3d3e844c23c64245d36c188c Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Sun, 24 Mar 2019 19:35:05 +0100 Subject: some more ternary --- test/monniaux/bitsliced-aes/bs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/monniaux/bitsliced-aes/bs.c') diff --git a/test/monniaux/bitsliced-aes/bs.c b/test/monniaux/bitsliced-aes/bs.c index f48faefa..4a9df4aa 100644 --- a/test/monniaux/bitsliced-aes/bs.c +++ b/test/monniaux/bitsliced-aes/bs.c @@ -14,6 +14,11 @@ #error "endianness not supported" #endif +#if 1 +#define TERNARY_XY0(t, x) ((-((t) != 0)) & (x)) +#else +#define TERNARY_XY0(t, x) (((t) != 0) ? (x) : (0)) +#endif void bs_addroundkey(word_t * B, word_t * rk) { @@ -391,11 +396,6 @@ void bs_transpose_dst(word_t * transpose, word_t * blocks) /* DM experiments */ /* The normal ternary operator costs us a lot! from 10145951 to 7995063 */ -#if 1 -#define TERNARY_XY0(t, x) ((-((t) != 0)) & (x)) -#else -#define TERNARY_XY0(t, x) (((t) != 0) ? (x) : (0)) -#endif int j; for(j=0; j < WORD_SIZE; j++) { @@ -496,7 +496,7 @@ void bs_transpose_rev(word_t * blocks) int j; for(j=0; j < WORD_SIZE; j++) { - word_t bit = (w & (ONE << j)) ? (ONE << (k % WORD_SIZE)) : 0; + word_t bit = TERNARY_XY0((w & (ONE << j)), (ONE << (k % WORD_SIZE))); transpose[j * WORDS_PER_BLOCK + (offset)] |= bit; } #else -- cgit