On Tue, 2023-12-05 at 17:21 +0800, chenxiaolong wrote: > According to your suggestion, the check of the built-in function was > modifiedin the simd_correctness_check.h file, and the types of the actual > parameters > of the built-in function were inconsistent with those of the formal > parameters. > The problems with the GCC regression test are as follows: > > ... > note: expected 'const void *' but argument is of type '__m128i' > error: incompatible type for argument 3 of 'ASSERTEQ_64' > ... > > The reason is that the types used in __m{128i,128,128d} are defined in > the vector header file (lsxintrin.h or lasxintrin.h), and their basic > types do not match the parameter types corresponding to the functions.
Ouch. I forgot that we are passing vectors themselves to ASSERTEQ_64, not the pointers. Now I come up with this: #include <cstdio> #include <cstring> #include <cstdlib> static inline void dump (const void *_ptr, int size, const char *name) { const char *ptr = (const char *)_ptr; printf("%s:", name); for (int i = 0; i < size; i++) printf(" %02hhx", ptr[i]); putchar('\n'); } template <class U, class V> static inline void assert_eq (const U &res, const V &ref, int line) { static_assert(sizeof (res) == sizeof (ref)); if (!memcmp (&res, &ref, sizeof(ref))) return; dump (res, sizeof (res), "res"); dump (ref, sizeof (ref), "ref"); } int main() { float x[4] = {}; int y[4] = {}; assert_eq(x, y, __LINE__); } This is C++, not C. But IMO we can port the tests to C++ anyway. -- Xi Ruoyao <xry...@xry111.site> School of Aerospace Science and Technology, Xidian University