]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: LoongArch: Enable 16B atomic tests if the test machine supports LSX and SCQ
authorXi Ruoyao <xry111@xry111.site>
Tue, 19 Aug 2025 03:01:56 +0000 (11:01 +0800)
committerXi Ruoyao <xry111@xry111.site>
Thu, 11 Sep 2025 10:49:36 +0000 (18:49 +0800)
Enable those tests so we won't make too stupid mistakes in 16B atomic
implementation anymore.

All these test passed on a Loongson 3C6000/S except
atomic-other-int128.c.  With GDB patched to support sc.q
(https://sourceware.org/pipermail/gdb-patches/2025-August/220034.html)
this test also XPASS.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp
(check_effective_target_loongarch_scq_hw): New.
(check_effective_target_sync_int_128_runtime): Return 1 on
loongarch64-*-* if hardware supports both LSX and SCQ.
* gcc.dg/atomic-compare-exchange-5.c: Pass -mlsx -mscq for
loongarch64-*-*.
* gcc.dg/atomic-exchange-5.c: Likewise.
* gcc.dg/atomic-load-5.c: Likewise.
* gcc.dg/atomic-op-5.c: Likewise.
* gcc.dg/atomic-store-5.c: Likewise.
* gcc.dg/atomic-store-6.c: Likewise.
* gcc.dg/simulate-thread/atomic-load-int128.c: Likewise.
* gcc.dg/simulate-thread/atomic-other-int128.c: Likewise.
(dg-final): xfail on loongarch64-*-* because  gdb does not
handle sc.q properly yet.

gcc/testsuite/gcc.dg/atomic-compare-exchange-5.c
gcc/testsuite/gcc.dg/atomic-exchange-5.c
gcc/testsuite/gcc.dg/atomic-load-5.c
gcc/testsuite/gcc.dg/atomic-op-5.c
gcc/testsuite/gcc.dg/atomic-store-5.c
gcc/testsuite/gcc.dg/atomic-store-6.c
gcc/testsuite/gcc.dg/simulate-thread/atomic-load-int128.c
gcc/testsuite/gcc.dg/simulate-thread/atomic-other-int128.c
gcc/testsuite/lib/target-supports.exp

index f5d071affe8f7d92a37efce333d9cfd0fb0b00c9..8d0b46262183c2348816f5ab10b79630fee69ccc 100644 (file)
@@ -3,6 +3,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target sync_int_128_runtime } */
 /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
 
 /* Test the execution of __atomic_compare_exchange_n builtin for an int_128.  */
 
index 190377f0cd55151b7035a62b280d40c9f10aa0de..ec3837dfdcf0050873f6f3eca1b533a99097d482 100644 (file)
@@ -3,6 +3,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target sync_int_128_runtime } */
 /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
 
 /* Test the execution of the __atomic_X builtin for a 16 byte value.  */
 
index d37d6424892741ff8ca452f037358f30b5900320..1cb2baabc7d10c06f6e08c6f238da3c59acbc0b8 100644 (file)
@@ -3,6 +3,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target sync_int_128_runtime } */
 /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
 
 extern void abort(void);
 
index 1407f3fe3b24e0da1a01b2eae4dd51abb9ba2611..4c6dcef8bf238df8ff6821378c4723069303abac 100644 (file)
@@ -3,6 +3,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target sync_int_128_runtime } */
 /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
 
 /* Test the execution of the __atomic_*OP builtin routines for an int_128.  */
 
index a855182bf49c6c5cbc665babfc01705423edf193..4bc379c722b2369f0673c9148b1f141bcc3deef3 100644 (file)
@@ -3,6 +3,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target sync_int_128_runtime } */
 /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
 
 /* Test the execution of the __atomic_store_n builtin for a 16 byte value.  */
 
index 81499cd716b34e11c0faaa8da98eb8c725480a7b..78bf2aa02f5dc1d4efe09a571e8ffdd297dce190 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target sync_int_128_runtime } */
 /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
 
 __int128_t i;
 
index 759a83d22f76614eb16b1473e61b6952b22887bd..6adc7d96620137d891a9f25d1979e840323ef8f2 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do link } */
 /* { dg-require-effective-target sync_int_128_runtime } */
 /* { dg-options "-mcx16" { target { x86_64-*-* i?86-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
 /* { dg-final { simulate-thread } } */
 
 #include <stdio.h>
index 6aaaa88ef0494632befed5cc8dc72e0feecd4822..5538fa1ff924b2b14050f5a8a5b5458875ed98bc 100644 (file)
@@ -1,7 +1,12 @@
 /* { dg-do link } */
 /* { dg-require-effective-target sync_int_128_runtime } */
 /* { dg-options "-mcx16" { target { x86_64-*-* i?86-*-* } } } */
-/* { dg-final { simulate-thread } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
+
+/* xfail on loongarch64 until the new GDB versions with
+   https://sourceware.org/pipermail/gdb-patches/2025-August/220034.html
+   is widely used by distros.  */
+/* { dg-final { simulate-thread { xfail loongarch64-*-* } } } */
 
 #include <stdio.h>
 #include "simulate-thread.h"
index 957fa7f3599e8965ed4c8e287bcbc740d70262e9..1acfb373bebb9050d41f67c63eb48f4e6b3284e1 100644 (file)
@@ -10053,7 +10053,13 @@ proc check_effective_target_sync_int_128 { } {
 # This requires support for both compare-and-swap and true atomic loads.
 
 proc check_effective_target_sync_int_128_runtime { } {
-    return 0
+    if { [istarget loongarch64-*-*]
+        && [check_effective_target_loongarch_sx_hw]
+        && [check_effective_target_loongarch_scq_hw] } {
+       return 1
+    } else {
+       return 0
+    }
 }
 
 # Return 1 if the target supports atomic operations on "long long".
@@ -14314,6 +14320,18 @@ proc check_effective_target_loongarch_asx_hw { } {
     } "-mlasx"]
 }
 
+proc check_effective_target_loongarch_scq_hw { } {
+    return [check_runtime loongarch_scq_hw {
+       #include <larchintrin.h>
+       int main (void)
+       {
+         if (__cpucfg (2) & (1 << 30))
+           return 0;
+         __builtin_trap ();
+       }
+    } ""]
+}
+
 # Check whether LoongArch binutils supports call36 relocation.
 proc check_effective_target_loongarch_call36_support { } {
   return [check_no_compiler_messages loongarch_call36_support object {