On Wed, 2025-02-12 at 18:03 +0800, Lulu Cheng wrote:

/* snip */

> diff --git a/gcc/testsuite/gcc.target/loongarch/pr118828-3.c 
> b/gcc/testsuite/gcc.target/loongarch/pr118828-3.c
> new file mode 100644
> index 00000000000..a682ae4a356
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/loongarch/pr118828-3.c
> @@ -0,0 +1,55 @@
> +/* { dg-do run } */
> +/* { dg-options "-march=loongarch64" } */
> +
> +#include <string.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +#ifndef __loongarch_arch
> +#error __loongarch_arch should not be available here
> +#endif

Hmm this seems not correct?  __loongarch_arch should be just
"loongarch64" here (at least it is "loongarch64" with GCC <= 14).

And a dg-do test with explicit -march= in dg-options is problematic
because it'll fail on less-capable CPUs (in this case, after we add
LA32).  We can change this to something like:

/* { dg-do compile } */
/* { dg-options "-O2 -march=loongarch64" } */
/* { dg-final { scan-assembler "t1: loongarch64" } } */
/* { dg-final { scan-assembler "t2: la64v1.1" } } */
/* { dg-final { scan-assembler "t3: loongarch64" } } */

void
t1 (void)
{
  asm volatile ("# t1: " __loongarch_arch);
}

#pragma GCC push_options
#pragma GCC target("arch=la64v1.1")

void
t2 (void)
{
  asm volatile ("# t2: " __loongarch_arch);
}

#pragma GCC pop_options

void
t3 (void)
{
  asm volatile ("# t3: " __loongarch_arch);
}

... ...

/* snip */

> diff --git a/gcc/testsuite/gcc.target/loongarch/pr118828-4.c 
> b/gcc/testsuite/gcc.target/loongarch/pr118828-4.c
> new file mode 100644
> index 00000000000..3b3a7c6078c
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/loongarch/pr118828-4.c
> @@ -0,0 +1,55 @@
> +/* { dg-do run } */
> +/* { dg-options "-mtune=la464" } */
> +
> +#include <string.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +#ifndef __loongarch_tune
> +#error __loongarch_tune should not be available here

Likewise.

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

Reply via email to