--- /dev/null
+/* { dg-do compile } */
+/* Verify that fence mappings match Table A.6's recommended mapping. */
+/* { dg-options "-O3" } */
+/* { dg-remove-options riscv_ztso } */
+/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+/*
+** fence_relaxed:
+** ret
+*/
+void fence_relaxed()
+{
+ __atomic_thread_fence(__ATOMIC_RELAXED);
+}
+
+/*
+** fence_acquire:
+** fence\tr,rw
+** ret
+*/
+void fence_acquire()
+{
+ __atomic_thread_fence(__ATOMIC_ACQUIRE);
+}
+
+/*
+** fence_release:
+** fence\trw,w
+** ret
+*/
+void fence_release()
+{
+ __atomic_thread_fence(__ATOMIC_RELEASE);
+}
+
+/*
+** fence_acq_rel:
+** fence\.tso
+** ret
+*/
+void fence_acq_rel()
+{
+ __atomic_thread_fence(__ATOMIC_ACQ_REL);
+}
+
+/*
+** fence_seq_cst:
+** fence\trw,rw
+** ret
+*/
+void fence_seq_cst()
+{
+ __atomic_thread_fence(__ATOMIC_SEQ_CST);
+}
+
--- /dev/null
+/* { dg-do compile } */
+/* Verify that fence mappings match the Ztso suggested mapping. */
+/* { dg-options "-O3" } */
+/* { dg-add-options riscv_ztso } */
+/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+/*
+** fence_relaxed:
+** ret
+*/
+void fence_relaxed()
+{
+ __atomic_thread_fence(__ATOMIC_RELAXED);
+}
+
+/*
+** fence_acquire:
+** ret
+*/
+void fence_acquire()
+{
+ __atomic_thread_fence(__ATOMIC_ACQUIRE);
+}
+
+/*
+** fence_release:
+** ret
+*/
+void fence_release()
+{
+ __atomic_thread_fence(__ATOMIC_RELEASE);
+}
+
+/*
+** fence_acq_rel:
+** ret
+*/
+void fence_acq_rel()
+{
+ __atomic_thread_fence(__ATOMIC_ACQ_REL);
+}
+
+/*
+** fence_seq_cst:
+** fence\trw,rw
+** ret
+*/
+void fence_seq_cst()
+{
+ __atomic_thread_fence(__ATOMIC_SEQ_CST);
+}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that atomic op mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zaamo } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** amoadd\.w\tzero,a1,0\(a0\)
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that atomic op mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zaamo } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** amoadd\.w\.aq\tzero,a1,0\(a0\)
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that atomic op mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zaamo } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** amoadd\.w\.rl\tzero,a1,0\(a0\)
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that atomic op mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zaamo } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** amoadd\.w\.aqrl\tzero,a1,0\(a0\)
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that atomic op mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zaamo } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** amoadd\.w\.aqrl\tzero,a1,0\(a0\)
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that fence mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** ret
-*/
-void foo()
-{
- __atomic_thread_fence(__ATOMIC_RELAXED);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that fence mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** fence\tr,rw
-** ret
-*/
-void foo()
-{
- __atomic_thread_fence(__ATOMIC_ACQUIRE);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that fence mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** fence\trw,w
-** ret
-*/
-void foo()
-{
- __atomic_thread_fence(__ATOMIC_RELEASE);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that fence mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** fence\.tso
-** ret
-*/
-void foo()
-{
- __atomic_thread_fence(__ATOMIC_ACQ_REL);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that fence mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** fence\trw,rw
-** ret
-*/
-void foo()
-{
- __atomic_thread_fence(__ATOMIC_SEQ_CST);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that atomic op mappings match the Ztso suggested mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zaamo } */
-/* { dg-add-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** amoadd\.w\tzero,a1,0\(a0\)
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that atomic op mappings the Ztso suggested mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zaamo } */
-/* { dg-add-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** amoadd\.w\tzero,a1,0\(a0\)
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that atomic op mappings match the Ztso suggested mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zaamo } */
-/* { dg-add-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** amoadd\.w\tzero,a1,0\(a0\)
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that atomic op mappings match the Ztso suggested mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zaamo } */
-/* { dg-add-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** amoadd\.w\tzero,a1,0\(a0\)
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that atomic op mappings match the Ztso suggested mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zaamo } */
-/* { dg-add-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** amoadd\.w\tzero,a1,0\(a0\)
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that fence mappings match the Ztso suggested mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** ret
-*/
-void foo()
-{
- __atomic_thread_fence(__ATOMIC_RELAXED);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that fence mappings match the Ztso suggested mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** ret
-*/
-void foo()
-{
- __atomic_thread_fence(__ATOMIC_ACQUIRE);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that fence mappings match the Ztso suggested mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** ret
-*/
-void foo()
-{
- __atomic_thread_fence(__ATOMIC_RELEASE);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that fence mappings match the Ztso suggested mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** ret
-*/
-void foo()
-{
- __atomic_thread_fence(__ATOMIC_ACQ_REL);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that fence mappings match the Ztso suggested mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** fence\trw,rw
-** ret
-*/
-void foo()
-{
- __atomic_thread_fence(__ATOMIC_SEQ_CST);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that lrsc atomic op mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zalrsc } */
-/* { dg-remove-options riscv_zaamo } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** 1:
-** lr.w\t[atx][0-9]+, 0\(a0\)
-** add\t[atx][0-9]+, [atx][0-9]+, a1
-** sc.w\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
-** bnez\t[atx][0-9]+, 1b
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that lrsc atomic op mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zalrsc } */
-/* { dg-remove-options riscv_zaamo } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** 1:
-** lr.w.aq\t[atx][0-9]+, 0\(a0\)
-** add\t[atx][0-9]+, [atx][0-9]+, a1
-** sc.w\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
-** bnez\t[atx][0-9]+, 1b
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that lrsc atomic op mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zalrsc } */
-/* { dg-remove-options riscv_zaamo } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** 1:
-** lr.w\t[atx][0-9]+, 0\(a0\)
-** add\t[atx][0-9]+, [atx][0-9]+, a1
-** sc.w.rl\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
-** bnez\t[atx][0-9]+, 1b
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that lrsc atomic op mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zalrsc } */
-/* { dg-remove-options riscv_zaamo } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** 1:
-** lr.w.aq\t[atx][0-9]+, 0\(a0\)
-** add\t[atx][0-9]+, [atx][0-9]+, a1
-** sc.w.rl\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
-** bnez\t[atx][0-9]+, 1b
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL);
-}
+++ /dev/null
-/* { dg-do compile } */
-/* Verify that lrsc atomic op mappings match Table A.6's recommended mapping. */
-/* { dg-options "-O3" } */
-/* { dg-add-options riscv_zalrsc } */
-/* { dg-remove-options riscv_zaamo } */
-/* { dg-remove-options riscv_ztso } */
-/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** foo:
-** 1:
-** lr.w.aqrl\t[atx][0-9]+, 0\(a0\)
-** add\t[atx][0-9]+, [atx][0-9]+, a1
-** sc.w.rl\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
-** bnez\t[atx][0-9]+, 1b
-** ret
-*/
-void foo (int* bar, int baz)
-{
- __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST);
-}
--- /dev/null
+/* { dg-do compile } */
+/* Verify that atomic op mappings match Table A.6's recommended mapping. */
+/* { dg-options "-O3" } */
+/* { dg-add-options riscv_zaamo } */
+/* { dg-remove-options riscv_ztso } */
+/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+/*
+** atomic_add_fetch_int_relaxed:
+** amoadd\.w\tzero,a1,0\(a0\)
+** ret
+*/
+void atomic_add_fetch_int_relaxed (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED);
+}
+
+/*
+** atomic_add_fetch_int_acquire:
+** amoadd\.w\.aq\tzero,a1,0\(a0\)
+** ret
+*/
+void atomic_add_fetch_int_acquire (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE);
+}
+
+/*
+** atomic_add_fetch_int_release:
+** amoadd\.w\.rl\tzero,a1,0\(a0\)
+** ret
+*/
+void atomic_add_fetch_int_release (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE);
+}
+
+/*
+** atomic_add_fetch_int_acq_rel:
+** amoadd\.w\.aqrl\tzero,a1,0\(a0\)
+** ret
+*/
+void atomic_add_fetch_int_acq_rel (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL);
+}
+
+/*
+** atomic_add_fetch_int_seq_cst:
+** amoadd\.w\.aqrl\tzero,a1,0\(a0\)
+** ret
+*/
+void atomic_add_fetch_int_seq_cst (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST);
+}
--- /dev/null
+/* { dg-do compile } */
+/* Verify that atomic op mappings match Table A.6's recommended mapping. */
+/* { dg-options "-O3" } */
+/* { dg-add-options riscv_zaamo } */
+/* { dg-add-options riscv_ztso } */
+/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+/*
+** atomic_add_fetch_int_relaxed:
+** amoadd\.w\tzero,a1,0\(a0\)
+** ret
+*/
+void atomic_add_fetch_int_relaxed (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED);
+}
+
+/*
+** atomic_add_fetch_int_acquire:
+** amoadd\.w\tzero,a1,0\(a0\)
+** ret
+*/
+void atomic_add_fetch_int_acquire (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE);
+}
+
+/*
+** atomic_add_fetch_int_release:
+** amoadd\.w\tzero,a1,0\(a0\)
+** ret
+*/
+void atomic_add_fetch_int_release (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE);
+}
+
+/*
+** atomic_add_fetch_int_acq_rel:
+** amoadd\.w\tzero,a1,0\(a0\)
+** ret
+*/
+void atomic_add_fetch_int_acq_rel (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL);
+}
+
+/*
+** atomic_add_fetch_int_seq_cst:
+** amoadd\.w\tzero,a1,0\(a0\)
+** ret
+*/
+void atomic_add_fetch_int_seq_cst (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST);
+}
--- /dev/null
+/* { dg-do compile } */
+/* Verify that lrsc atomic op mappings match the PSABI doc's recommended mapping. */
+/* { dg-options "-O3" } */
+/* { dg-add-options riscv_zalrsc } */
+/* { dg-remove-options riscv_zaamo } */
+/* { dg-remove-options riscv_ztso } */
+/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+/*
+** atomic_add_fetch_int_relaxed:
+** 1:
+** lr.w\t[atx][0-9]+, 0\(a0\)
+** add\t[atx][0-9]+, [atx][0-9]+, a1
+** sc.w\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
+** bnez\t[atx][0-9]+, 1b
+** ret
+*/
+void atomic_add_fetch_int_relaxed (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED);
+}
+
+/*
+** atomic_add_fetch_int_acquire:
+** 1:
+** lr.w.aq\t[atx][0-9]+, 0\(a0\)
+** add\t[atx][0-9]+, [atx][0-9]+, a1
+** sc.w\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
+** bnez\t[atx][0-9]+, 1b
+** ret
+*/
+void atomic_add_fetch_int_acquire (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE);
+}
+
+/*
+** atomic_add_fetch_int_release:
+** 1:
+** lr.w\t[atx][0-9]+, 0\(a0\)
+** add\t[atx][0-9]+, [atx][0-9]+, a1
+** sc.w.rl\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
+** bnez\t[atx][0-9]+, 1b
+** ret
+*/
+void atomic_add_fetch_int_release (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE);
+}
+
+/*
+** atomic_add_fetch_int_acq_rel:
+** 1:
+** lr.w.aq\t[atx][0-9]+, 0\(a0\)
+** add\t[atx][0-9]+, [atx][0-9]+, a1
+** sc.w.rl\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
+** bnez\t[atx][0-9]+, 1b
+** ret
+*/
+void atomic_add_fetch_int_acq_rel (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL);
+}
+
+/*
+** atomic_add_fetch_int_seq_cst:
+** 1:
+** lr.w.aqrl\t[atx][0-9]+, 0\(a0\)
+** add\t[atx][0-9]+, [atx][0-9]+, a1
+** sc.w.rl\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
+** bnez\t[atx][0-9]+, 1b
+** ret
+*/
+void atomic_add_fetch_int_seq_cst (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST);
+}
--- /dev/null
+/* { dg-do compile } */
+/* Verify that lrsc atomic op mappings match the PSABI doc's recommended mapping. */
+/* { dg-options "-O3" } */
+/* { dg-add-options riscv_zalrsc } */
+/* { dg-add-options riscv_ztso } */
+/* { dg-remove-options riscv_zaamo } */
+/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+/*
+** atomic_add_fetch_int_relaxed:
+** 1:
+** lr.w\t[atx][0-9]+, 0\(a0\)
+** add\t[atx][0-9]+, [atx][0-9]+, a1
+** sc.w\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
+** bnez\t[atx][0-9]+, 1b
+** ret
+*/
+void atomic_add_fetch_int_relaxed (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED);
+}
+
+/*
+** atomic_add_fetch_int_acquire:
+** 1:
+** lr.w\t[atx][0-9]+, 0\(a0\)
+** add\t[atx][0-9]+, [atx][0-9]+, a1
+** sc.w\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
+** bnez\t[atx][0-9]+, 1b
+** ret
+*/
+void atomic_add_fetch_int_acquire (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE);
+}
+
+/*
+** atomic_add_fetch_int_release:
+** 1:
+** lr.w\t[atx][0-9]+, 0\(a0\)
+** add\t[atx][0-9]+, [atx][0-9]+, a1
+** sc.w\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
+** bnez\t[atx][0-9]+, 1b
+** ret
+*/
+void atomic_add_fetch_int_release (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE);
+}
+
+/*
+** atomic_add_fetch_int_acq_rel:
+** 1:
+** lr.w\t[atx][0-9]+, 0\(a0\)
+** add\t[atx][0-9]+, [atx][0-9]+, a1
+** sc.w\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
+** bnez\t[atx][0-9]+, 1b
+** ret
+*/
+void atomic_add_fetch_int_acq_rel (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL);
+}
+
+/*
+** atomic_add_fetch_int_seq_cst:
+** 1:
+** lr.w.aqrl\t[atx][0-9]+, 0\(a0\)
+** add\t[atx][0-9]+, [atx][0-9]+, a1
+** sc.w.rl\t[atx][0-9]+, [atx][0-9]+, 0\(a0\)
+** bnez\t[atx][0-9]+, 1b
+** ret
+*/
+void atomic_add_fetch_int_seq_cst (int* bar, int baz)
+{
+ __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST);
+}