@@ -62,9 +62,12 @@ namespace xsimd
6262 static constexpr size_t rvv_width_mf4 = XSIMD_RVV_BITS / 4 ;
6363 static constexpr size_t rvv_width_mf2 = XSIMD_RVV_BITS / 2 ;
6464 static constexpr size_t rvv_width_m1 = XSIMD_RVV_BITS;
65- static constexpr size_t rvv_width_m2 = XSIMD_RVV_BITS * 2 ;
66- static constexpr size_t rvv_width_m4 = XSIMD_RVV_BITS * 4 ;
67- static constexpr size_t rvv_width_m8 = XSIMD_RVV_BITS * 8 ;
65+
66+ // Cope with gcc limitation, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116484
67+ #define XSIMD_RVV_WIDTH_MF8 (XSIMD_RVV_BITS / 8 )
68+ #define XSIMD_RVV_WIDTH_MF4 (XSIMD_RVV_BITS / 4 )
69+ #define XSIMD_RVV_WIDTH_MF2 (XSIMD_RVV_BITS / 2 )
70+ #define XSIMD_RVV_WIDTH_M1 XSIMD_RVV_BITS
6871
6972 // rvv_type_info is a utility class to convert scalar type and
7073 // bitwidth into rvv register types.
@@ -79,30 +82,30 @@ namespace xsimd
7982 //
8083 template <class T , size_t Width>
8184 struct rvv_type_info ;
82- #define XSIMD_RVV_MAKE_TYPE (scalar, t, s, vmul ) \
83- template <> \
84- struct rvv_type_info <scalar, rvv_width_m1 * vmul> \
85- { \
86- static constexpr size_t width = rvv_width_m1 * vmul; \
87- using type = XSIMD_RVV_TYPE(t, s, vmul); \
88- using byte_type = XSIMD_RVV_TYPE(u, 8 , vmul); \
89- using fixed_type = type __attribute__ ((riscv_rvv_vector_bits(width))); \
90- template <class U > \
91- static XSIMD_INLINE type bitcast (U x) noexcept \
92- { \
93- const auto words = XSIMD_RVV_JOINT5 (__riscv_vreinterpret_, u, s, m, vmul)(x); \
94- return XSIMD_RVV_JOINT5 (__riscv_vreinterpret_, t, s, m, vmul)(words); \
95- } \
96- template <> \
97- XSIMD_INLINE type bitcast<type>(type x) noexcept { return x; } \
98- template < class U > \
99- static XSIMD_INLINE byte_type as_bytes (U x) noexcept \
100- { \
101- static_assert (std::is_same<U, type>::value, " inconsistent conversion types " ); \
102- const auto words = XSIMD_RVV_JOINT5 (__riscv_vreinterpret_, u, s, m, vmul)(x); \
103- return XSIMD_RVV_JOINT5 (__riscv_vreinterpret_, u, 8 , m, vmul)(words); \
104- } \
105- };
85+ #define XSIMD_RVV_MAKE_TYPE (scalar, t, s, vmul ) \
86+ template <> \
87+ struct rvv_type_info <scalar, rvv_width_m1 * vmul> \
88+ { \
89+ static constexpr size_t width = rvv_width_m1 * vmul; \
90+ using type = XSIMD_RVV_TYPE(t, s, vmul); \
91+ using byte_type = XSIMD_RVV_TYPE(u, 8 , vmul); \
92+ using fixed_type = type __attribute__ ((riscv_rvv_vector_bits(/* width= */ XSIMD_RVV_WIDTH_M1 * vmul ))); \
93+ template <class U > \
94+ static XSIMD_INLINE type bitcast (U x) noexcept \
95+ { \
96+ const auto words = XSIMD_RVV_JOINT5 (__riscv_vreinterpret_, u, s, m, vmul)(x); \
97+ return XSIMD_RVV_JOINT5 (__riscv_vreinterpret_, t, s, m, vmul)(words); \
98+ } \
99+ template <class U > \
100+ static XSIMD_INLINE byte_type as_bytes (U x) noexcept \
101+ { \
102+ static_assert (std::is_same<U, type>::value, " inconsistent conversion types " ); \
103+ const auto words = XSIMD_RVV_JOINT5 (__riscv_vreinterpret_, u, s, m, vmul)(x); \
104+ return XSIMD_RVV_JOINT5 (__riscv_vreinterpret_, u, 8 , m, vmul)(words); \
105+ } \
106+ }; \
107+ template <> \
108+ XSIMD_INLINE XSIMD_RVV_TYPE (t, s, vmul) rvv_type_info<scalar, rvv_width_m1 * vmul>::bitcast<XSIMD_RVV_TYPE(t, s, vmul)>(XSIMD_RVV_TYPE(t, s, vmul) x) noexcept { return x; }
106109
107110#define XSIMD_RVV_MAKE_TYPES (vmul ) \
108111 XSIMD_RVV_MAKE_TYPE (int8_t , i, 8 , vmul) \
@@ -235,17 +238,17 @@ namespace xsimd
235238 template <>
236239 struct semitype <2 >
237240 {
238- using type = vuint8mf2_t __attribute__ ((riscv_rvv_vector_bits(rvv_width_mf2 )));
241+ using type = vuint8mf2_t __attribute__ ((riscv_rvv_vector_bits(XSIMD_RVV_WIDTH_MF2 )));
239242 };
240243 template <>
241244 struct semitype <4 >
242245 {
243- using type = vuint8mf4_t __attribute__ ((riscv_rvv_vector_bits(rvv_width_mf4 )));
246+ using type = vuint8mf4_t __attribute__ ((riscv_rvv_vector_bits(XSIMD_RVV_WIDTH_MF4 )));
244247 };
245248 template <>
246249 struct semitype <8 >
247250 {
248- using type = vuint8mf8_t __attribute__ ((riscv_rvv_vector_bits(rvv_width_mf8 )));
251+ using type = vuint8mf8_t __attribute__ ((riscv_rvv_vector_bits(XSIMD_RVV_WIDTH_MF8 )));
249252 };
250253 using fixed_type = typename semitype<divisor>::type;
251254 using super::as_bytes;
@@ -374,7 +377,7 @@ namespace xsimd
374377 struct rvv_bool
375378 {
376379 using bool_info = rvv_bool_info<rvv_width_m1 * sizeof (T) * 8 / Width>;
377- using storage_type = vuint8m1_t __attribute__ ((riscv_rvv_vector_bits(rvv_width_m1 )));
380+ using storage_type = vuint8m1_t __attribute__ ((riscv_rvv_vector_bits(XSIMD_RVV_WIDTH_M1 )));
378381 using type = typename bool_info::type;
379382 storage_type value;
380383 rvv_bool () = default ;
@@ -489,6 +492,12 @@ namespace xsimd
489492 using type = detail::rvv_bool_simd_register<T>;
490493 };
491494 } // namespace types
495+
496+ #undef XSIMD_RVV_WIDTH_MF8
497+ #undef XSIMD_RVV_WIDTH_MF4
498+ #undef XSIMD_RVV_WIDTH_MF2
499+ #undef XSIMD_RVV_WIDTH_M1
500+
492501#else
493502 using rvv = detail::rvv<0xFFFFFFFF >;
494503#endif
0 commit comments