Skip to content

Add basic scalar __arm_sc_* implementations - #94

Merged
Wilco1 merged 1 commit into
ARM-software:masterfrom
rockdreamer:add_arm_sc
Jun 11, 2026
Merged

Wilco1 merged 1 commit into
ARM-software:masterfrom
rockdreamer:add_arm_sc

Conversation

@rockdreamer

@rockdreamer rockdreamer commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor
  • We can reuse the aarch64 implementation of memmove and memcpy for their streaming compatible versions as none of them make use of incompatible instructions and perform quite well.
  • Memset is based on the current aarch64 implementation but does not make use of AdvSIMD instructions.
  • Memchr is an implementation of the algorithm described in the Hacker's delight book.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution to Arm's optimized routines. Contribution to this repository does require a signed contributor's license agreement. See contributor-agreement.pdf for details

@TamarChristinaArm
TamarChristinaArm requested a review from Wilco1 June 3, 2026 15:51
@rockdreamer
rockdreamer force-pushed the add_arm_sc branch 2 times, most recently from 7c4fb40 to 1d4dd2d Compare June 9, 2026 15:37
Comment thread string/aarch64/memcpy.S Outdated
Comment thread string/include/stringlib.h Outdated
Comment thread string/aarch64/memset-scalar.S
Comment thread string/aarch64/memset-scalar.S Outdated
Comment thread string/aarch64/memset-scalar.S Outdated
Comment thread string/aarch64/memchr-sc.S Outdated
Comment thread string/aarch64/memchr-scalar.S Outdated
Comment thread string/aarch64/memchr-scalar.S Outdated
Comment thread string/aarch64/memchr-scalar.S Outdated

@Wilco1 Wilco1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting to look good, just a few more issues

We can reuse the aarch64 implementation of memmove and memcpy for their streaming compatible versions as none of them make use of incompatible instructions and perform quite well.
Memset is based on the current aarch64 implementation but does not make use of AdvSIMD instructions.
Memchr is an implementation of the algorithm described in the
Hacker's delight book.
@Wilco1
Wilco1 merged commit e3458f8 into ARM-software:master Jun 11, 2026
8 checks passed
@rockdreamer
rockdreamer deleted the add_arm_sc branch June 11, 2026 20:59
faraz-mtk pushed a commit to MediaTek-Labs/gcc that referenced this pull request Jun 29, 2026
… libgcc

The ACLE[1] specified the following four functions in "Streaming-compatible
versions of standard routines" as having "the same behavior as the standard C
functions that they are named after" and external linkage.

- void *__arm_sc_memcpy(void *dest, const void *src, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memmove(void *dest, const void *src, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memset(void *s, int c, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memchr(void *s, int c, size_t n)
    __arm_streaming_compatible;

Declarations for these are already available in arm_sme.h
This patch provides implementations for these based entirely on scalar
operations, along with basic tests that exercise the code both in streaming and
non-streaming mode.

See also [2] for further testing.

[1] https://arm-software.github.io/acle/main/acle.html
[2] ARM-software/optimized-routines#94

libgcc/ChangeLog:
	* config/aarch64/__arm_sc_memchr_scalar.S: New file.
	* config/aarch64/__arm_sc_memcpy_scalar.S: Likewise.
	* config/aarch64/__arm_sc_memset_scalar.S: Likewise.
	* config/aarch64/libgcc-sme.ver (GCC_17.0): Export
	__arm_sc_memchr, __arm_sc_memcpy, __arm_sc_memmove and
	__arm_sc_memset.
	* config/aarch64/t-aarch64: Add new files.
	* config/aarch64/aarch64-asm.h: Add ENTRY_ALIAS.

gcc/testsuite/ChangeLog:
	* gcc.target/aarch64/acle/arm_sc_memchr.c: New file.
	* gcc.target/aarch64/acle/arm_sc_memcpy.c: Likewise.
	* gcc.target/aarch64/acle/arm_sc_memmove.c: Likewise.
	* gcc.target/aarch64/acle/arm_sc_memset.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memchr.c: New file.
	* gcc.target/aarch64/sme/arm_sc_memcpy.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memmove.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memset.c: Likewise.
jthillard pushed a commit to fpetrot/riscv-gcc that referenced this pull request Jul 13, 2026
… libgcc

The ACLE[1] specified the following four functions in "Streaming-compatible
versions of standard routines" as having "the same behavior as the standard C
functions that they are named after" and external linkage.

- void *__arm_sc_memcpy(void *dest, const void *src, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memmove(void *dest, const void *src, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memset(void *s, int c, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memchr(void *s, int c, size_t n)
    __arm_streaming_compatible;

Declarations for these are already available in arm_sme.h
This patch provides implementations for these based entirely on scalar
operations, along with basic tests that exercise the code both in streaming and
non-streaming mode.

See also [2] for further testing.

[1] https://arm-software.github.io/acle/main/acle.html
[2] ARM-software/optimized-routines#94

libgcc/ChangeLog:
	* config/aarch64/__arm_sc_memchr_scalar.S: New file.
	* config/aarch64/__arm_sc_memcpy_scalar.S: Likewise.
	* config/aarch64/__arm_sc_memset_scalar.S: Likewise.
	* config/aarch64/libgcc-sme.ver (GCC_17.0): Export
	__arm_sc_memchr, __arm_sc_memcpy, __arm_sc_memmove and
	__arm_sc_memset.
	* config/aarch64/t-aarch64: Add new files.
	* config/aarch64/aarch64-asm.h: Add ENTRY_ALIAS.

gcc/testsuite/ChangeLog:
	* gcc.target/aarch64/acle/arm_sc_memchr.c: New file.
	* gcc.target/aarch64/acle/arm_sc_memcpy.c: Likewise.
	* gcc.target/aarch64/acle/arm_sc_memmove.c: Likewise.
	* gcc.target/aarch64/acle/arm_sc_memset.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memchr.c: New file.
	* gcc.target/aarch64/sme/arm_sc_memcpy.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memmove.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memset.c: Likewise.
jthillard pushed a commit to fpetrot/riscv-gcc that referenced this pull request Jul 15, 2026
… libgcc

The ACLE[1] specified the following four functions in "Streaming-compatible
versions of standard routines" as having "the same behavior as the standard C
functions that they are named after" and external linkage.

- void *__arm_sc_memcpy(void *dest, const void *src, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memmove(void *dest, const void *src, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memset(void *s, int c, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memchr(void *s, int c, size_t n)
    __arm_streaming_compatible;

Declarations for these are already available in arm_sme.h
This patch provides implementations for these based entirely on scalar
operations, along with basic tests that exercise the code both in streaming and
non-streaming mode.

See also [2] for further testing.

[1] https://arm-software.github.io/acle/main/acle.html
[2] ARM-software/optimized-routines#94

libgcc/ChangeLog:
	* config/aarch64/__arm_sc_memchr_scalar.S: New file.
	* config/aarch64/__arm_sc_memcpy_scalar.S: Likewise.
	* config/aarch64/__arm_sc_memset_scalar.S: Likewise.
	* config/aarch64/libgcc-sme.ver (GCC_17.0): Export
	__arm_sc_memchr, __arm_sc_memcpy, __arm_sc_memmove and
	__arm_sc_memset.
	* config/aarch64/t-aarch64: Add new files.
	* config/aarch64/aarch64-asm.h: Add ENTRY_ALIAS.

gcc/testsuite/ChangeLog:
	* gcc.target/aarch64/acle/arm_sc_memchr.c: New file.
	* gcc.target/aarch64/acle/arm_sc_memcpy.c: Likewise.
	* gcc.target/aarch64/acle/arm_sc_memmove.c: Likewise.
	* gcc.target/aarch64/acle/arm_sc_memset.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memchr.c: New file.
	* gcc.target/aarch64/sme/arm_sc_memcpy.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memmove.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memset.c: Likewise.
jthillard pushed a commit to fpetrot/riscv-gcc that referenced this pull request Jul 15, 2026
… libgcc

The ACLE[1] specified the following four functions in "Streaming-compatible
versions of standard routines" as having "the same behavior as the standard C
functions that they are named after" and external linkage.

- void *__arm_sc_memcpy(void *dest, const void *src, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memmove(void *dest, const void *src, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memset(void *s, int c, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memchr(void *s, int c, size_t n)
    __arm_streaming_compatible;

Declarations for these are already available in arm_sme.h
This patch provides implementations for these based entirely on scalar
operations, along with basic tests that exercise the code both in streaming and
non-streaming mode.

See also [2] for further testing.

[1] https://arm-software.github.io/acle/main/acle.html
[2] ARM-software/optimized-routines#94

libgcc/ChangeLog:
	* config/aarch64/__arm_sc_memchr_scalar.S: New file.
	* config/aarch64/__arm_sc_memcpy_scalar.S: Likewise.
	* config/aarch64/__arm_sc_memset_scalar.S: Likewise.
	* config/aarch64/libgcc-sme.ver (GCC_17.0): Export
	__arm_sc_memchr, __arm_sc_memcpy, __arm_sc_memmove and
	__arm_sc_memset.
	* config/aarch64/t-aarch64: Add new files.
	* config/aarch64/aarch64-asm.h: Add ENTRY_ALIAS.

gcc/testsuite/ChangeLog:
	* gcc.target/aarch64/acle/arm_sc_memchr.c: New file.
	* gcc.target/aarch64/acle/arm_sc_memcpy.c: Likewise.
	* gcc.target/aarch64/acle/arm_sc_memmove.c: Likewise.
	* gcc.target/aarch64/acle/arm_sc_memset.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memchr.c: New file.
	* gcc.target/aarch64/sme/arm_sc_memcpy.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memmove.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memset.c: Likewise.
jthillard pushed a commit to fpetrot/riscv-gcc that referenced this pull request Jul 15, 2026
… libgcc

The ACLE[1] specified the following four functions in "Streaming-compatible
versions of standard routines" as having "the same behavior as the standard C
functions that they are named after" and external linkage.

- void *__arm_sc_memcpy(void *dest, const void *src, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memmove(void *dest, const void *src, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memset(void *s, int c, size_t n)
    __arm_streaming_compatible;
- void *__arm_sc_memchr(void *s, int c, size_t n)
    __arm_streaming_compatible;

Declarations for these are already available in arm_sme.h
This patch provides implementations for these based entirely on scalar
operations, along with basic tests that exercise the code both in streaming and
non-streaming mode.

See also [2] for further testing.

[1] https://arm-software.github.io/acle/main/acle.html
[2] ARM-software/optimized-routines#94

libgcc/ChangeLog:
	* config/aarch64/__arm_sc_memchr_scalar.S: New file.
	* config/aarch64/__arm_sc_memcpy_scalar.S: Likewise.
	* config/aarch64/__arm_sc_memset_scalar.S: Likewise.
	* config/aarch64/libgcc-sme.ver (GCC_17.0): Export
	__arm_sc_memchr, __arm_sc_memcpy, __arm_sc_memmove and
	__arm_sc_memset.
	* config/aarch64/t-aarch64: Add new files.
	* config/aarch64/aarch64-asm.h: Add ENTRY_ALIAS.

gcc/testsuite/ChangeLog:
	* gcc.target/aarch64/acle/arm_sc_memchr.c: New file.
	* gcc.target/aarch64/acle/arm_sc_memcpy.c: Likewise.
	* gcc.target/aarch64/acle/arm_sc_memmove.c: Likewise.
	* gcc.target/aarch64/acle/arm_sc_memset.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memchr.c: New file.
	* gcc.target/aarch64/sme/arm_sc_memcpy.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memmove.c: Likewise.
	* gcc.target/aarch64/sme/arm_sc_memset.c: Likewise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants