Skip to content

Commit 8ffcc7d

Browse files
committed
Revert "optimize constant_time_conditional_memxor for gcc".
This reverts commit 9b3ef1b. It seems like the casts in the loop violate strict aliasing rules. This may result in a performance regression when GCC is used instead of Clang, as this code path was added specifically for GCC to address this performance difference.
1 parent 59f2370 commit 8ffcc7d

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

crypto/internal.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,6 @@ static inline void constant_time_conditional_memxor(void *dst, const void *src,
263263
debug_assert_nonsecret(!buffers_alias(dst, n, src, n));
264264
aliasing_uint8_t *out = dst;
265265
const aliasing_uint8_t *in = src;
266-
#if defined(__GNUC__) && !defined(__clang__)
267-
// gcc 13.2.0 doesn't automatically vectorize this loop regardless of barrier
268-
typedef aliasing_uint8_t v32u8 __attribute__((vector_size(32), aligned(1), may_alias));
269-
size_t n_vec = n&~(size_t)31;
270-
v32u8 masks = ((aliasing_uint8_t)mask-(v32u8){}); // broadcast
271-
for (size_t i = 0; i < n_vec; i += 32) {
272-
*(v32u8*)&out[i] ^= masks & *(v32u8 const*)&in[i];
273-
}
274-
out += n_vec;
275-
n -= n_vec;
276-
#endif
277266
for (size_t i = 0; i < n; i++) {
278267
out[i] ^= value_barrier_w(mask) & in[i];
279268
}

0 commit comments

Comments
 (0)