On Mon, 2023-12-04 at 20:14 +0800, chenxiaolong wrote:
> On LoongArch architecture, using the latest gcc14 in regression test,
> it is found that the vector test cases in vector directory appear FAIL
> entries with unmatched pointer types. In order to solve this kind of
> problem, the type of the variable in the check result is modified with
> the parameter type defined in the vector builtin function.

IMO we should write something more readable:

static inline
void ASSERTEQ_64 (int line, const void *_ref, const void *_res)
{
  if (memcmp (_ref, _res, 16) == 0)
    return;

  const char *ref = (const char *)_ref;
  const char *res = (const char *)_res;

  printf ("error %s:%d: result mismatch\n", __FILE__, line);

  printf ("ref:");
  for (int i = 0; i < 16; i++)
    printf (" %02x", ref[i]);

  printf ("\nres:");
  for (int i = 0; i < 16; i++)
    printf (" %02x", res[i]);

  putchar ('\n');
  abort ();
}

> gcc/testsuite/ChangeLog:
> 
>       * gcc.target/loongarch/vector/simd_correctness_check.h:The variable
>       types in the check results are modified in conjunction with the
>       parameter types defined in the vector builtin function.
> ---
>  .../gcc.target/loongarch/vector/simd_correctness_check.h     | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git 
> a/gcc/testsuite/gcc.target/loongarch/vector/simd_correctness_check.h 
> b/gcc/testsuite/gcc.target/loongarch/vector/simd_correctness_check.h
> index eb7fbd59cc7..f780f6586b3 100644
> --- a/gcc/testsuite/gcc.target/loongarch/vector/simd_correctness_check.h
> +++ b/gcc/testsuite/gcc.target/loongarch/vector/simd_correctness_check.h
> @@ -8,7 +8,8 @@
>        int fail = 0;                                                          
>  \
>        for (size_t i = 0; i < sizeof (res) / sizeof (res[0]); ++i)            
>  \
>          {                                                                    
>  \
> -          long *temp_ref = &ref[i], *temp_res = &res[i];                     
>  \
> +          long long *temp_ref = (long long *)&ref[i],                        
>  \
> +             *temp_res = (long long *)&res[i];                             \
>            if (abs (*temp_ref - *temp_res) > 0)                               
>  \
>              {                                                                
>  \
>                printf (" error: %s at line %ld , expected " #ref              
>  \
> @@ -28,7 +29,7 @@
>        int fail = 0;                                                          
>  \
>        for (size_t i = 0; i < sizeof (res) / sizeof (res[0]); ++i)            
>  \
>          {                                                                    
>  \
> -          int *temp_ref = &ref[i], *temp_res = &res[i];                      
>  \
> +          int *temp_ref = (int *)&ref[i], *temp_res = (int *)&res[i];        
>  \
>            if (abs (*temp_ref - *temp_res) > 0)                               
>  \
>              {                                                                
>  \
>                printf (" error: %s at line %ld , expected " #ref              
>  \

-- 
Xi Ruoyao <xry...@xry111.site>
School of Aerospace Science and Technology, Xidian University

Reply via email to