https://gcc.gnu.org/g:613f842711ad76e684def949582d3235170baeb4

commit r17-5122-g613f842711ad76e684def949582d3235170baeb4
Author: Richard Ball <[email protected]>
Date:   Tue Oct 13 15:34:09 2026 +0100

    aarch64: Update atomic_fetch_with_hint to use correct values.
    
    Following a change to the ACLE, the hint values have been
    standardised across fetch and store, this patch updates GCC
    to match the current state of the ACLE.
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64-builtins.cc
            (aarch64_expand_atomic_hints_builtins_fetch): Change 
require_const_argument.
            * config/aarch64/atomics.md: Change values in hint value switch.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/aarch64/atomic_fetch_add_with_shuh.c: Update test.
            * gcc.target/aarch64/atomic_fetch_and_with_shuh.c: Likewise.
            * gcc.target/aarch64/atomic_fetch_or_with_shuh.c: Likewise.
            * gcc.target/aarch64/atomic_fetch_sub_with_shuh.c: Likewise.
            * gcc.target/aarch64/atomic_fetch_xor_with_shuh.c: Likewise.

Diff:
---
 gcc/config/aarch64/aarch64-builtins.cc                 |  2 +-
 gcc/config/aarch64/atomics.md                          |  4 ++--
 .../gcc.target/aarch64/atomic_fetch_add_with_shuh.c    | 18 +++++++++---------
 .../gcc.target/aarch64/atomic_fetch_and_with_shuh.c    | 18 +++++++++---------
 .../gcc.target/aarch64/atomic_fetch_or_with_shuh.c     | 18 +++++++++---------
 .../gcc.target/aarch64/atomic_fetch_sub_with_shuh.c    | 18 +++++++++---------
 .../gcc.target/aarch64/atomic_fetch_xor_with_shuh.c    | 18 +++++++++---------
 7 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-builtins.cc 
b/gcc/config/aarch64/aarch64-builtins.cc
index 148cf0ecd1be..fd7020049764 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -4109,7 +4109,7 @@ aarch64_expand_atomic_hints_builtins_fetch (tree exp)
   rtx hint = expand_normal (CALL_EXPR_ARG (exp, 3));
   rtx fetch_type = expand_normal (CALL_EXPR_ARG (exp, 4));
 
-  require_const_argument (exp, 3, 0, 2);
+  require_const_argument (exp, 3, 3, 5);
   require_const_argument (exp, 2, 0, 6);
   require_const_argument (exp, 4, 0, 6);
   if (seen_error ())
diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md
index 0cddbfa9b3d1..87e955b713c7 100644
--- a/gcc/config/aarch64/atomics.md
+++ b/gcc/config/aarch64/atomics.md
@@ -805,10 +805,10 @@
   {
     switch (INTVAL (operands[4]))
     {
-      case 0:
+      case 3:
        output_asm_insn ("shuh", operands);
        break;
-      case 1:
+      case 4:
        output_asm_insn ("shuh\tph", operands);
        break;
       default:
diff --git a/gcc/testsuite/gcc.target/aarch64/atomic_fetch_add_with_shuh.c 
b/gcc/testsuite/gcc.target/aarch64/atomic_fetch_add_with_shuh.c
index 9844979848c6..2679d83da5fa 100644
--- a/gcc/testsuite/gcc.target/aarch64/atomic_fetch_add_with_shuh.c
+++ b/gcc/testsuite/gcc.target/aarch64/atomic_fetch_add_with_shuh.c
@@ -18,7 +18,7 @@ testFun1 ()
   char* ptr1 = &item1;
   char test1 = 1;
 
-  return __arm_atomic_fetch_add_with_hint (ptr1, test1, __ATOMIC_RELAXED, 0);
+  return __arm_atomic_fetch_add_with_hint (ptr1, test1, __ATOMIC_RELAXED, 3);
 }
 
 /*
@@ -34,7 +34,7 @@ testFun2 ()
   short item2 = 10;
   short* ptr2 = &item2;
   short test2 = 11;
-  return __arm_atomic_fetch_add_with_hint (ptr2, test2, __ATOMIC_RELEASE, 0);
+  return __arm_atomic_fetch_add_with_hint (ptr2, test2, __ATOMIC_RELEASE, 3);
 }
 
 /*
@@ -50,7 +50,7 @@ testFun3 ()
   unsigned int item3 = 10;
   unsigned int* ptr3 = &item3;
   unsigned int test3 = 11;
-  return __arm_atomic_fetch_add_with_hint (ptr3, test3, __ATOMIC_SEQ_CST, 1);
+  return __arm_atomic_fetch_add_with_hint (ptr3, test3, __ATOMIC_SEQ_CST, 4);
 }
 
 /*
@@ -66,7 +66,7 @@ testFun4 ()
   long item4 = 10;
   long* ptr4 = &item4;
   long test4 = 11;
-  __arm_atomic_fetch_add_with_hint (ptr4, test4, __ATOMIC_RELAXED, 1);
+  __arm_atomic_fetch_add_with_hint (ptr4, test4, __ATOMIC_RELAXED, 4);
 }
 
 /*
@@ -84,7 +84,7 @@ testFun5 ()
   long **ptr5 = &ptritem;
   long test5item = 11;
   long *test5 = &test5item;
-  __arm_atomic_fetch_add_with_hint (ptr5, test5, __ATOMIC_SEQ_CST, 0);
+  __arm_atomic_fetch_add_with_hint (ptr5, test5, __ATOMIC_SEQ_CST, 3);
 }
 
 /*
@@ -101,7 +101,7 @@ testFun6 ()
   char* ptr8 = &item8;
   long test8 = 1;
 
-  __arm_atomic_fetch_add_with_hint (ptr8, test8, __ATOMIC_RELAXED, 0);
+  __arm_atomic_fetch_add_with_hint (ptr8, test8, __ATOMIC_RELAXED, 3);
 }
 
 /*
@@ -117,7 +117,7 @@ static char buf[8];
 void
 testFun7 (void)
 {
-  __arm_atomic_fetch_add_with_hint((buf + 1), (char)7, __ATOMIC_RELAXED, 1);
+  __arm_atomic_fetch_add_with_hint((buf + 1), (char)7, __ATOMIC_RELAXED, 4);
 }
 
 
@@ -132,7 +132,7 @@ testFun7 (void)
 long
 signed_fetch_add_hint (int x, int *p)
 {
-  return __arm_atomic_fetch_add_with_hint (p, x, __ATOMIC_RELAXED, 1);
+  return __arm_atomic_fetch_add_with_hint (p, x, __ATOMIC_RELAXED, 4);
 }
 
 
@@ -147,5 +147,5 @@ signed_fetch_add_hint (int x, int *p)
 long
 unsigned_fetch_add_hint (unsigned int x, unsigned int *p)
 {
-  return __arm_atomic_fetch_add_with_hint (p, x, __ATOMIC_RELAXED, 1);
+  return __arm_atomic_fetch_add_with_hint (p, x, __ATOMIC_RELAXED, 4);
 }
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.target/aarch64/atomic_fetch_and_with_shuh.c 
b/gcc/testsuite/gcc.target/aarch64/atomic_fetch_and_with_shuh.c
index 35c919ca7698..ee2a032f5e16 100644
--- a/gcc/testsuite/gcc.target/aarch64/atomic_fetch_and_with_shuh.c
+++ b/gcc/testsuite/gcc.target/aarch64/atomic_fetch_and_with_shuh.c
@@ -18,7 +18,7 @@ testFun1 ()
   char* ptr1 = &item1;
   char test1 = 1;
 
-  return __arm_atomic_fetch_and_with_hint (ptr1, test1, __ATOMIC_RELAXED, 0);
+  return __arm_atomic_fetch_and_with_hint (ptr1, test1, __ATOMIC_RELAXED, 3);
 }
 
 /*
@@ -34,7 +34,7 @@ testFun2 ()
   short item2 = 10;
   short* ptr2 = &item2;
   short test2 = 11;
-  return __arm_atomic_fetch_and_with_hint (ptr2, test2, __ATOMIC_RELEASE, 0);
+  return __arm_atomic_fetch_and_with_hint (ptr2, test2, __ATOMIC_RELEASE, 3);
 }
 
 /*
@@ -50,7 +50,7 @@ testFun3 ()
   unsigned int item3 = 10;
   unsigned int* ptr3 = &item3;
   unsigned int test3 = 11;
-  return __arm_atomic_fetch_and_with_hint (ptr3, test3, __ATOMIC_SEQ_CST, 1);
+  return __arm_atomic_fetch_and_with_hint (ptr3, test3, __ATOMIC_SEQ_CST, 4);
 }
 
 /*
@@ -66,7 +66,7 @@ testFun4 ()
   long item4 = 10;
   long* ptr4 = &item4;
   long test4 = 11;
-  __arm_atomic_fetch_and_with_hint (ptr4, test4, __ATOMIC_RELAXED, 1);
+  __arm_atomic_fetch_and_with_hint (ptr4, test4, __ATOMIC_RELAXED, 4);
 }
 
 /*
@@ -84,7 +84,7 @@ testFun5 ()
   long **ptr5 = &ptritem;
   long test5item = 11;
   long *test5 = &test5item;
-  __arm_atomic_fetch_and_with_hint (ptr5, test5, __ATOMIC_SEQ_CST, 0);
+  __arm_atomic_fetch_and_with_hint (ptr5, test5, __ATOMIC_SEQ_CST, 3);
 }
 
 /*
@@ -101,7 +101,7 @@ testFun6 ()
   char* ptr8 = &item8;
   long test8 = 1;
 
-  __arm_atomic_fetch_and_with_hint (ptr8, test8, __ATOMIC_RELAXED, 0);
+  __arm_atomic_fetch_and_with_hint (ptr8, test8, __ATOMIC_RELAXED, 3);
 }
 
 /*
@@ -117,7 +117,7 @@ static char buf[8];
 void
 testFun7 (void)
 {
-  __arm_atomic_fetch_and_with_hint((buf + 1), (char)7, __ATOMIC_RELAXED, 1);
+  __arm_atomic_fetch_and_with_hint((buf + 1), (char)7, __ATOMIC_RELAXED, 4);
 }
 
 /*
@@ -131,7 +131,7 @@ testFun7 (void)
 long
 signed_fetch_and_hint (int x, int *p)
 {
-  return __arm_atomic_fetch_and_with_hint (p, x, __ATOMIC_RELAXED, 1);
+  return __arm_atomic_fetch_and_with_hint (p, x, __ATOMIC_RELAXED, 4);
 }
 
 
@@ -146,5 +146,5 @@ signed_fetch_and_hint (int x, int *p)
 long
 unsigned_fetch_and_hint (unsigned int x, unsigned int *p)
 {
-  return __arm_atomic_fetch_and_with_hint (p, x, __ATOMIC_RELAXED, 1);
+  return __arm_atomic_fetch_and_with_hint (p, x, __ATOMIC_RELAXED, 4);
 }
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.target/aarch64/atomic_fetch_or_with_shuh.c 
b/gcc/testsuite/gcc.target/aarch64/atomic_fetch_or_with_shuh.c
index 02661254ad0f..e2156865e6cd 100644
--- a/gcc/testsuite/gcc.target/aarch64/atomic_fetch_or_with_shuh.c
+++ b/gcc/testsuite/gcc.target/aarch64/atomic_fetch_or_with_shuh.c
@@ -18,7 +18,7 @@ testFun1 ()
   char* ptr1 = &item1;
   char test1 = 1;
 
-  return __arm_atomic_fetch_or_with_hint (ptr1, test1, __ATOMIC_RELAXED, 0);
+  return __arm_atomic_fetch_or_with_hint (ptr1, test1, __ATOMIC_RELAXED, 3);
 }
 
 /*
@@ -34,7 +34,7 @@ testFun2 ()
   short item2 = 10;
   short* ptr2 = &item2;
   short test2 = 11;
-  return __arm_atomic_fetch_or_with_hint (ptr2, test2, __ATOMIC_RELEASE, 0);
+  return __arm_atomic_fetch_or_with_hint (ptr2, test2, __ATOMIC_RELEASE, 3);
 }
 
 /*
@@ -50,7 +50,7 @@ testFun3 ()
   unsigned int item3 = 10;
   unsigned int* ptr3 = &item3;
   unsigned int test3 = 11;
-  return __arm_atomic_fetch_or_with_hint (ptr3, test3, __ATOMIC_SEQ_CST, 1);
+  return __arm_atomic_fetch_or_with_hint (ptr3, test3, __ATOMIC_SEQ_CST, 4);
 }
 
 /*
@@ -66,7 +66,7 @@ testFun4 ()
   long item4 = 10;
   long* ptr4 = &item4;
   long test4 = 11;
-  __arm_atomic_fetch_or_with_hint (ptr4, test4, __ATOMIC_RELAXED, 1);
+  __arm_atomic_fetch_or_with_hint (ptr4, test4, __ATOMIC_RELAXED, 4);
 }
 
 /*
@@ -84,7 +84,7 @@ testFun5 ()
   long **ptr5 = &ptritem;
   long test5item = 11;
   long *test5 = &test5item;
-  __arm_atomic_fetch_or_with_hint (ptr5, test5, __ATOMIC_SEQ_CST, 0);
+  __arm_atomic_fetch_or_with_hint (ptr5, test5, __ATOMIC_SEQ_CST, 3);
 }
 
 /*
@@ -101,7 +101,7 @@ testFun6 ()
   char* ptr8 = &item8;
   long test8 = 1;
 
-  __arm_atomic_fetch_or_with_hint (ptr8, test8, __ATOMIC_RELAXED, 0);
+  __arm_atomic_fetch_or_with_hint (ptr8, test8, __ATOMIC_RELAXED, 3);
 }
 
 /*
@@ -117,7 +117,7 @@ static char buf[8];
 void
 testFun7 (void)
 {
-  __arm_atomic_fetch_or_with_hint((buf + 1), (char)7, __ATOMIC_RELAXED, 1);
+  __arm_atomic_fetch_or_with_hint((buf + 1), (char)7, __ATOMIC_RELAXED, 4);
 }
 
 /*
@@ -131,7 +131,7 @@ testFun7 (void)
 long
 signed_fetch_or_hint (int x, int *p)
 {
-  return __arm_atomic_fetch_or_with_hint (p, x, __ATOMIC_RELAXED, 1);
+  return __arm_atomic_fetch_or_with_hint (p, x, __ATOMIC_RELAXED, 4);
 }
 
 
@@ -146,5 +146,5 @@ signed_fetch_or_hint (int x, int *p)
 long
 unsigned_fetch_or_hint (unsigned int x, unsigned int *p)
 {
-  return __arm_atomic_fetch_or_with_hint (p, x, __ATOMIC_RELAXED, 1);
+  return __arm_atomic_fetch_or_with_hint (p, x, __ATOMIC_RELAXED, 4);
 }
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.target/aarch64/atomic_fetch_sub_with_shuh.c 
b/gcc/testsuite/gcc.target/aarch64/atomic_fetch_sub_with_shuh.c
index 04b400fe7b36..726a73582254 100644
--- a/gcc/testsuite/gcc.target/aarch64/atomic_fetch_sub_with_shuh.c
+++ b/gcc/testsuite/gcc.target/aarch64/atomic_fetch_sub_with_shuh.c
@@ -21,7 +21,7 @@ testFun1 ()
   char* ptr1 = &item1;
   char test1 = 1;
 
-  return __arm_atomic_fetch_sub_with_hint (ptr1, test1, __ATOMIC_RELAXED, 0);
+  return __arm_atomic_fetch_sub_with_hint (ptr1, test1, __ATOMIC_RELAXED, 3);
 }
 
 /*
@@ -38,7 +38,7 @@ testFun2 ()
   short item2 = 10;
   short* ptr2 = &item2;
   short test2 = 11;
-  return __arm_atomic_fetch_sub_with_hint (ptr2, test2, __ATOMIC_RELEASE, 0);
+  return __arm_atomic_fetch_sub_with_hint (ptr2, test2, __ATOMIC_RELEASE, 3);
 }
 
 /*
@@ -55,7 +55,7 @@ testFun3 ()
   unsigned int item3 = 10;
   unsigned int* ptr3 = &item3;
   unsigned int test3 = 11;
-  return __arm_atomic_fetch_sub_with_hint (ptr3, test3, __ATOMIC_SEQ_CST, 1);
+  return __arm_atomic_fetch_sub_with_hint (ptr3, test3, __ATOMIC_SEQ_CST, 4);
 }
 
 /*
@@ -74,7 +74,7 @@ testFun4 ()
   long item4 = 10;
   long* ptr4 = &item4;
   long test4 = 11;
-  __arm_atomic_fetch_sub_with_hint (ptr4, test4, __ATOMIC_RELAXED, 1);
+  __arm_atomic_fetch_sub_with_hint (ptr4, test4, __ATOMIC_RELAXED, 4);
 }
 
 /*
@@ -93,7 +93,7 @@ testFun5 ()
   long **ptr5 = &ptritem;
   long test5item = 11;
   long *test5 = &test5item;
-  __arm_atomic_fetch_sub_with_hint (ptr5, test5, __ATOMIC_SEQ_CST, 0);
+  __arm_atomic_fetch_sub_with_hint (ptr5, test5, __ATOMIC_SEQ_CST, 3);
 }
 
 /*
@@ -113,7 +113,7 @@ testFun6 ()
   char* ptr8 = &item8;
   long test8 = 1;
 
-  __arm_atomic_fetch_sub_with_hint (ptr8, test8, __ATOMIC_RELAXED, 0);
+  __arm_atomic_fetch_sub_with_hint (ptr8, test8, __ATOMIC_RELAXED, 3);
 }
 
 /*
@@ -129,7 +129,7 @@ static char buf[8];
 void
 testFun7 (void)
 {
-  __arm_atomic_fetch_sub_with_hint((buf + 1), (char)7, __ATOMIC_RELAXED, 1);
+  __arm_atomic_fetch_sub_with_hint((buf + 1), (char)7, __ATOMIC_RELAXED, 4);
 }
 
 /*
@@ -143,7 +143,7 @@ testFun7 (void)
 long
 signed_fetch_sub_hint (int x, int *p)
 {
-  return __arm_atomic_fetch_sub_with_hint (p, x, __ATOMIC_RELAXED, 1);
+  return __arm_atomic_fetch_sub_with_hint (p, x, __ATOMIC_RELAXED, 4);
 }
 
 
@@ -158,5 +158,5 @@ signed_fetch_sub_hint (int x, int *p)
 long
 unsigned_fetch_sub_hint (unsigned int x, unsigned int *p)
 {
-  return __arm_atomic_fetch_sub_with_hint (p, x, __ATOMIC_RELAXED, 1);
+  return __arm_atomic_fetch_sub_with_hint (p, x, __ATOMIC_RELAXED, 4);
 }
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.target/aarch64/atomic_fetch_xor_with_shuh.c 
b/gcc/testsuite/gcc.target/aarch64/atomic_fetch_xor_with_shuh.c
index 2aa4f8daee25..8f7d78e2a61c 100644
--- a/gcc/testsuite/gcc.target/aarch64/atomic_fetch_xor_with_shuh.c
+++ b/gcc/testsuite/gcc.target/aarch64/atomic_fetch_xor_with_shuh.c
@@ -18,7 +18,7 @@ testFun1 ()
   char* ptr1 = &item1;
   char test1 = 1;
 
-  return __arm_atomic_fetch_xor_with_hint (ptr1, test1, __ATOMIC_RELAXED, 0);
+  return __arm_atomic_fetch_xor_with_hint (ptr1, test1, __ATOMIC_RELAXED, 3);
 }
 
 /*
@@ -34,7 +34,7 @@ testFun2 ()
   short item2 = 10;
   short* ptr2 = &item2;
   short test2 = 11;
-  return __arm_atomic_fetch_xor_with_hint (ptr2, test2, __ATOMIC_RELEASE, 0);
+  return __arm_atomic_fetch_xor_with_hint (ptr2, test2, __ATOMIC_RELEASE, 3);
 }
 
 /*
@@ -50,7 +50,7 @@ testFun3 ()
   unsigned int item3 = 10;
   unsigned int* ptr3 = &item3;
   unsigned int test3 = 11;
-  return __arm_atomic_fetch_xor_with_hint (ptr3, test3, __ATOMIC_SEQ_CST, 1);
+  return __arm_atomic_fetch_xor_with_hint (ptr3, test3, __ATOMIC_SEQ_CST, 4);
 }
 
 /*
@@ -66,7 +66,7 @@ testFun4 ()
   long item4 = 10;
   long* ptr4 = &item4;
   long test4 = 11;
-  __arm_atomic_fetch_xor_with_hint (ptr4, test4, __ATOMIC_RELAXED, 1);
+  __arm_atomic_fetch_xor_with_hint (ptr4, test4, __ATOMIC_RELAXED, 4);
 }
 
 /*
@@ -84,7 +84,7 @@ testFun5 ()
   long **ptr5 = &ptritem;
   long test5item = 11;
   long *test5 = &test5item;
-  __arm_atomic_fetch_xor_with_hint (ptr5, test5, __ATOMIC_SEQ_CST, 0);
+  __arm_atomic_fetch_xor_with_hint (ptr5, test5, __ATOMIC_SEQ_CST, 3);
 }
 
 /*
@@ -101,7 +101,7 @@ testFun6 ()
   char* ptr8 = &item8;
   long test8 = 1;
 
-  __arm_atomic_fetch_xor_with_hint (ptr8, test8, __ATOMIC_RELAXED, 0);
+  __arm_atomic_fetch_xor_with_hint (ptr8, test8, __ATOMIC_RELAXED, 3);
 }
 
 /*
@@ -117,7 +117,7 @@ static char buf[8];
 void
 testFun7 (void)
 {
-  __arm_atomic_fetch_xor_with_hint((buf + 1), (char)7, __ATOMIC_RELAXED, 1);
+  __arm_atomic_fetch_xor_with_hint((buf + 1), (char)7, __ATOMIC_RELAXED, 4);
 }
 
 /*
@@ -131,7 +131,7 @@ testFun7 (void)
 long
 signed_fetch_xor_hint (int x, int *p)
 {
-  return __arm_atomic_fetch_xor_with_hint (p, x, __ATOMIC_RELAXED, 1);
+  return __arm_atomic_fetch_xor_with_hint (p, x, __ATOMIC_RELAXED, 4);
 }
 
 
@@ -146,5 +146,5 @@ signed_fetch_xor_hint (int x, int *p)
 long
 unsigned_fetch_xor_hint (unsigned int x, unsigned int *p)
 {
-  return __arm_atomic_fetch_xor_with_hint (p, x, __ATOMIC_RELAXED, 1);
+  return __arm_atomic_fetch_xor_with_hint (p, x, __ATOMIC_RELAXED, 4);
 }
\ No newline at end of file

Reply via email to