Skip to content

Commit e5402d1

Browse files
committed
Fix load complex
1 parent b45a1f2 commit e5402d1

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

include/xsimd/arch/xsimd_rvv.hpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,14 @@ namespace xsimd
383383
namespace detail_rvv
384384
{
385385
template <class T, size_t Width>
386-
XSIMD_INLINE detail_rvv::rvv_reg_t<T, Width> broadcast(T arg) noexcept
386+
XSIMD_INLINE rvv_reg_t<T, Width> broadcast(T arg) noexcept
387387
{
388388
// A bit of a dance, here, because rvvmv_splat has no other
389389
// argument from which to deduce type, and T=char is not
390390
// supported.
391391
project_num_t<T> arg_not_char(arg);
392-
const auto splat = detail_rvv::rvvmv_splat(arg_not_char);
393-
return detail_rvv::rvv_reg_t<T, Width>(splat.get_bytes(), types::detail::XSIMD_RVV_BITCAST);
392+
const auto splat = rvvmv_splat(arg_not_char);
393+
return rvv_reg_t<T, Width>(splat.get_bytes(), types::detail::XSIMD_RVV_BITCAST);
394394
}
395395
}
396396

@@ -464,16 +464,23 @@ namespace xsimd
464464
return __riscv_vslidedown(vv, vv.vl / 2, vv.vl);
465465
}
466466

467+
}
468+
469+
// Must be in detail::load_complex for use by common memory.
470+
// ODR violation are prevented because the size of the register is encoded
471+
// in batch.
472+
namespace detail
473+
{
467474
template <class A, class T, detail::enable_floating_point_t<T> = 0>
468475
XSIMD_INLINE batch<std::complex<T>, A> load_complex(batch<T, A> const& lo, batch<T, A> const& hi, requires_arch<rvv>) noexcept
469476
{
470-
const auto real_index = vindex<A, as_unsigned_integer_t<T>, 0, 1>();
471-
const auto imag_index = vindex<A, as_unsigned_integer_t<T>, 1, 1>();
472-
const auto index = rvvabut<as_unsigned_integer_t<T>, A::width>(real_index, imag_index);
473-
const auto input = rvvabut<T, A::width>(lo.data, hi.data);
474-
const rvv_reg_t<T, A::width * 2> result = __riscv_vrgather(input, index, index.vl);
477+
const auto real_index = detail_rvv::vindex<A, as_unsigned_integer_t<T>, 0, 1>();
478+
const auto imag_index = detail_rvv::vindex<A, as_unsigned_integer_t<T>, 1, 1>();
479+
const auto index = detail_rvv::rvvabut<as_unsigned_integer_t<T>, A::width>(real_index, imag_index);
480+
const auto input = detail_rvv::rvvabut<T, A::width>(lo.data, hi.data);
481+
const detail_rvv::rvv_reg_t<T, A::width * 2> result = __riscv_vrgather(input, index, index.vl);
475482

476-
return { rvvget_lo<T, A::width>(result), rvvget_hi<T, A::width>(result) };
483+
return { detail_rvv::rvvget_lo<T, A::width>(result), detail_rvv::rvvget_hi<T, A::width>(result) };
477484
}
478485
}
479486

0 commit comments

Comments
 (0)