在 2023-12-05二的 20:44 +0800,Xi Ruoyao写道:
> 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.
> 
 Following your idea, I tried to change C into C++ code. The problem is
that the tests cases of LoongArch architecture are written in the style
of C language, and the code changed to C++ involves more problems and
is not easy to completely modify. So it's best to keep the C language
style. 

Reply via email to