在 2025/2/12 下午6:19, Xi Ruoyao 写道:
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).
Well, because this predefined macro must be defined in any case, I added
this check here.
But it seems a bit redundant. I will delete it in v3.
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:
What I didn't take into account was...
/* { 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.