Skip to content

Commit eb1c1ba

Browse files
committed
fix: declare register_type conversion operator on batch
Some toolchains (notably certain GCC builds) define shift and mul immediate intrinsics as macros that apply a textual C-style cast to their operand. That cast does not traverse the multi-level alias inheritance of simd_register (e.g. avx512bw -> avx512dq -> avx512cd -> avx512f), so a batch<T, ISA> fails to convert to its native register type in those contexts. Declare the conversion operator on batch itself so the native type is always one member-lookup away.
1 parent 80c2362 commit eb1c1ba

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

include/xsimd/types/xsimd_batch.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ namespace xsimd
129129
XSIMD_INLINE explicit batch(batch_bool_type const& b) noexcept;
130130
XSIMD_INLINE batch(register_type reg) noexcept;
131131

132+
/* Redeclare the conversion operator at the most-derived level. Some
133+
* compilers fail to invoke the conversion inherited from
134+
* types::simd_register when a batch is fed to an intrinsic defined as
135+
* a macro (e.g. certain GCC shift/mullo imm intrinsics), because the
136+
* textual C-style cast inside the macro does not traverse the alias
137+
* inheritance chain. Declaring the operator here makes it visible on
138+
* the batch type directly. */
139+
XSIMD_INLINE operator register_type() const noexcept
140+
{
141+
return this->data;
142+
}
143+
132144
template <class U>
133145
XSIMD_NO_DISCARD static XSIMD_INLINE batch broadcast(U val) noexcept;
134146

0 commit comments

Comments
 (0)