SSE PacketMath Compilation Error on QNX
Summary
Type mismatch compilation error when the eigen_packet_wrapper type is used.
When Packet4f is eigen_packet_wrapper<__m128>, this code fails:
to[stride * 1] = pfirst(_mm_shuffle_ps(from, from, 1));
_mm_shuffle_ps() returns __m128, but pfirst() expects Packet4f (the wrapper type). No implicit conversion exists.
Environment
- Operating System : Qnx
- Architecture : x86_64
- Eigen Version : 5.0.0
-
Compiler Version : qcc
8.3.0 20190222 (stable) [qnx710 1568#58] - Compile Flags : -std=c++17 -msse2
- Vector Extension : SSE2/AVX
Minimal Example
#include <Eigen/Core>
int main()
{
float data[8] = {0, 0, 0, 0, 0, 0, 0, 0};
Eigen::internal::Packet4f packet = Eigen::internal::pset1<Eigen::internal::Packet4f>(42.0F);
Eigen::internal::pscatter(data, packet, 2);
return 0;
}
Steps to reproduce
curl -fsSL https://gitlab.com/libeigen/eigen/-/archive/5.0.0/eigen-5.0.0.tar.gz | tar -xz -C /tmp- QNX:
qcc -std=c++17 -msse2 -I/tmp/eigen-5.0.0 eigen_sse_bug_reproducer.cpp - Linux:
g++ -std=c++17 -mavx -fabi-version=3 -I/tmp/eigen-5.0.0 eigen_sse_bug_reproducer.cpp
What is the current bug behavior?
external/eigen~/Eigen/src/Core/arch/SSE/PacketMath.h: In function 'void Eigen::internal::pscatter(Scalar*, const Packet&, Eigen::Index) [with Scalar = float; Packet = Eigen::internal::eigen_packet_wrapper<__vector(4) float>; Eigen::Index = long int]':
external/eigen~/Eigen/src/Core/arch/SSE/PacketMath.h:1682:56: error: cannot convert 'Eigen::internal::unpacket_traits<__vector(4) float>::type' {aka '__vector(4) float'} to 'float' in assignment
to[stride * 1] = pfirst(_mm_shuffle_ps(from, from, 1));
^
external/eigen~/Eigen/src/Core/arch/SSE/PacketMath.h:1683:56: error: cannot convert 'Eigen::internal::unpacket_traits<__vector(4) float>::type' {aka '__vector(4) float'} to 'float' in assignment
to[stride * 2] = pfirst(_mm_shuffle_ps(from, from, 2));
^
external/eigen~/Eigen/src/Core/arch/SSE/PacketMath.h:1684:56: error: cannot convert 'Eigen::internal::unpacket_traits<__vector(4) float>::type' {aka '__vector(4) float'} to 'float' in assignment
to[stride * 3] = pfirst(_mm_shuffle_ps(from, from, 3));
^
What is the expected correct behavior?
compiles
Anything else that might help
- Compilation suceeds on
3.4.1. - https://gitlab.com/libeigen/eigen/-/blob/eea6587b0e9faa56e425001607c225647f760caf/Eigen/src/Core/arch/SSE/PacketMath.h#L1679-1685
- Claude suggests:
--- Eigen/src/Core/arch/SSE/PacketMath.h
+++ Eigen/src/Core/arch/SSE/PacketMath.h
@@ -1678,9 +1678,9 @@ EIGEN_STRONG_INLINE void pscatter<float, Packet4f>(float* to, const Packet4f& f
template <>
EIGEN_STRONG_INLINE void pscatter<float, Packet4f>(float* to, const Packet4f& from, Index stride) {
to[stride * 0] = pfirst(from);
- to[stride * 1] = pfirst(_mm_shuffle_ps(from, from, 1));
- to[stride * 2] = pfirst(_mm_shuffle_ps(from, from, 2));
- to[stride * 3] = pfirst(_mm_shuffle_ps(from, from, 3));
+ to[stride * 1] = pfirst(Packet4f(_mm_shuffle_ps(from, from, 1)));
+ to[stride * 2] = pfirst(Packet4f(_mm_shuffle_ps(from, from, 2)));
+ to[stride * 3] = pfirst(Packet4f(_mm_shuffle_ps(from, from, 3)));
}
template <>
EIGEN_STRONG_INLINE void pscatter<double, Packet2d>(double* to, const Packet2d& from, Index stride) {