Skip to content

Commit

Permalink
[WIP] Fix clang-17 miscompilation of __riscv_vreinterpret_u8m8
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-sans-paille committed Oct 15, 2024
1 parent e4e871c commit 6e59683
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions include/xsimd/types/xsimd_rvv_register.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,50 @@ namespace xsimd
} \
template <> \
XSIMD_INLINE type bitcast<type>(type x) noexcept { return x; } \
template <> \
XSIMD_INLINE type bitcast<byte_type>(byte_type x) noexcept \
{ \
return XSIMD_RVV_JOINT5(__riscv_vreinterpret_, t, s, m, vmul)(x); \
} \
static XSIMD_INLINE byte_type as_bytes(type x) noexcept \
{ \
const auto words = XSIMD_RVV_JOINT5(__riscv_vreinterpret_, u, s, m, vmul)(x); \
return XSIMD_RVV_JOINT5(__riscv_vreinterpret_, u, 8, m, vmul)(words); \
} \
};

#define XSIMD_RVV_MAKE_TYPES(vmul) \
XSIMD_RVV_MAKE_TYPE(int8_t, i, 8, vmul) \
XSIMD_RVV_MAKE_TYPE(uint8_t, u, 8, vmul) \
XSIMD_RVV_MAKE_TYPE(int16_t, i, 16, vmul) \
XSIMD_RVV_MAKE_TYPE(uint16_t, u, 16, vmul) \
XSIMD_RVV_MAKE_TYPE(int32_t, i, 32, vmul) \
XSIMD_RVV_MAKE_TYPE(uint32_t, u, 32, vmul) \
XSIMD_RVV_MAKE_TYPE(int64_t, i, 64, vmul) \
XSIMD_RVV_MAKE_TYPE(uint64_t, u, 64, vmul) \
XSIMD_RVV_MAKE_TYPE(float, f, 32, vmul) \
#define XSIMD_RVV_MAKE_BTYPE(scalar, t, s, vmul) \
template <> \
struct rvv_type_info<scalar, rvv_width_m1 * vmul> \
{ \
static constexpr size_t width = rvv_width_m1 * vmul; \
using type = XSIMD_RVV_TYPE(t, s, vmul); \
using byte_type = XSIMD_RVV_TYPE(u, 8, vmul); \
using fixed_type = type __attribute__((riscv_rvv_vector_bits(width))); \
template <class U> \
static XSIMD_INLINE type bitcast(U x) noexcept \
{ \
const auto words = XSIMD_RVV_JOINT5(__riscv_vreinterpret_, u, s, m, vmul)(x); \
return XSIMD_RVV_JOINT5(__riscv_vreinterpret_, t, s, m, vmul)(words); \
} \
template <> \
XSIMD_INLINE type bitcast<type>(type x) noexcept { return x; } \
static XSIMD_INLINE byte_type as_bytes(type x) noexcept \
{ \
return x; \
} \
};

#define XSIMD_RVV_MAKE_TYPES(vmul) \
XSIMD_RVV_MAKE_TYPE(int8_t, i, 8, vmul) \
XSIMD_RVV_MAKE_BTYPE(uint8_t, u, 8, vmul) \
XSIMD_RVV_MAKE_TYPE(int16_t, i, 16, vmul) \
XSIMD_RVV_MAKE_TYPE(uint16_t, u, 16, vmul) \
XSIMD_RVV_MAKE_TYPE(int32_t, i, 32, vmul) \
XSIMD_RVV_MAKE_TYPE(uint32_t, u, 32, vmul) \
XSIMD_RVV_MAKE_TYPE(int64_t, i, 64, vmul) \
XSIMD_RVV_MAKE_TYPE(uint64_t, u, 64, vmul) \
XSIMD_RVV_MAKE_TYPE(float, f, 32, vmul) \
XSIMD_RVV_MAKE_TYPE(double, f, 64, vmul)

XSIMD_RVV_MAKE_TYPES(8)
Expand Down

0 comments on commit 6e59683

Please sign in to comment.