public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: chenxiaolong <chenxiaolong@loongson.cn>, gcc-patches@gcc.gnu.org
Cc: i@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn
Subject: Re: [PATCH v1] LoongArch: Modify the check type of the vector builtin function.
Date: Tue, 05 Dec 2023 20:44:10 +0800	[thread overview]
Message-ID: <4f4b78a06d9b677fa21964f652cc60a05cf161bb.camel@xry111.site> (raw)
In-Reply-To: <d6b8e5be984d1778ac035bbd1b7c61eb5c0f817c.camel@loongson.cn>

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 <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2023-12-05 12:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04 12:14 chenxiaolong
2023-12-04 12:31 ` Xi Ruoyao
2023-12-04 12:38   ` Xi Ruoyao
2023-12-05  9:21     ` chenxiaolong
2023-12-05 12:44       ` Xi Ruoyao [this message]
2023-12-07  3:21         ` chenxiaolong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f4b78a06d9b677fa21964f652cc60a05cf161bb.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=chenglulu@loongson.cn \
    --cc=chenxiaolong@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=i@xen0n.name \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).