Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions src/intrin_portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,6 @@ FORCE_INLINE rx_vec_f128 rx_sqrt_vec_f128(rx_vec_f128 a) {
return (rx_vec_f128)vec_sqrt(a);
}

FORCE_INLINE rx_vec_i128 rx_set1_long_vec_i128(uint64_t a) {
return (rx_vec_i128)vec_splat2sd(a);
}

FORCE_INLINE rx_vec_f128 rx_vec_i128_vec_f128(rx_vec_i128 a) {
return (rx_vec_f128)a;
}

FORCE_INLINE rx_vec_f128 rx_set_vec_f128(uint64_t x1, uint64_t x0) {
return (rx_vec_f128)(__m128ll){x0,x1};
}
Expand All @@ -277,11 +269,19 @@ FORCE_INLINE rx_vec_f128 rx_set1_vec_f128(uint64_t x) {
}

FORCE_INLINE rx_vec_f128 rx_cast_vec_i2f(rx_vec_i128 a) {
#if defined(NATIVE_LITTLE_ENDIAN)
return (rx_vec_f128)a;
#else
return (rx_vec_f128)vec_perm((__m128i)a, (__m128i)a, (__m128i){4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11});
#endif
}

FORCE_INLINE rx_vec_i128 rx_cast_vec_f2i(rx_vec_f128 a) {
#if defined(NATIVE_LITTLE_ENDIAN)
return (rx_vec_i128)a;
#else
return (rx_vec_i128)vec_perm((__m128i)a, (__m128i)a, (__m128i){4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11});
#endif
}

FORCE_INLINE rx_vec_f128 rx_xor_vec_f128(rx_vec_f128 a, rx_vec_f128 b) {
Expand Down Expand Up @@ -632,19 +632,6 @@ FORCE_INLINE rx_vec_f128 rx_sqrt_vec_f128(rx_vec_f128 a) {
return x;
}

FORCE_INLINE rx_vec_i128 rx_set1_long_vec_i128(uint64_t a) {
rx_vec_i128 x;
x.u64[0] = a;
x.u64[1] = a;
return x;
}

FORCE_INLINE rx_vec_f128 rx_vec_i128_vec_f128(rx_vec_i128 a) {
rx_vec_f128 x;
x.i = a;
return x;
}

FORCE_INLINE rx_vec_f128 rx_set_vec_f128(uint64_t x1, uint64_t x0) {
rx_vec_f128 v;
v.i.u64[0] = x0;
Expand Down
10 changes: 10 additions & 0 deletions src/tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ int main() {
assert(equalsHex(state, "fa89397dd6ca422513aeadba3f124b5540324c4ad4b6db434394307a17c833ab"));
});

runTest("rx_cast_vec_f2i / rx_cast_vec_i2f", true, []() {
alignas(16) uint8_t in[16], out[16];
for (int i = 0; i < 16; ++i)
in[i] = (uint8_t)(0x11 * i + 1);
rx_store_vec_i128((rx_vec_i128*)out, rx_cast_vec_f2i(rx_load_vec_f128((const double*)in)));
assert(memcmp(in, out, sizeof(in)) == 0);
rx_store_vec_f128((double*)out, rx_cast_vec_i2f(rx_load_vec_i128((const rx_vec_i128*)in)));
assert(memcmp(in, out, sizeof(in)) == 0);
});

randomx::NativeRegisterFile reg;
randomx::BytecodeMachine decoder;
randomx::InstructionByteCode ibc;
Expand Down
Loading