Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RISC-V and unaligned memory access #1670

Open
ccawley2011 opened this issue Feb 16, 2024 · 1 comment
Open

RISC-V and unaligned memory access #1670

ccawley2011 opened this issue Feb 16, 2024 · 1 comment
Labels
Architecture Architecture specific

Comments

@ccawley2011
Copy link
Contributor

The RISC-V chunkset code includes the line uint##elen##_t val = *(uint##elen##_t*)from; as part of the CHUNK_MEMSET_RVV_IMPL, however all the other chunkset implementations use alignment-safe reads here. RISC-V also doesn't define UNALIGNED_OK, and looking at the output from Compiler Explorer shows that both memcpy and __attribute__ ((__packed__, __may_alias__)) read one byte at a time for smaller sizes. Is using unaligned reads intentional here?

@mtl1979
Copy link
Collaborator

mtl1979 commented Feb 16, 2024

AFAIK RISC-V traps on unaligned loads and stores, but can handle them in M-mode. In case of reads, it will read more and shift the result to get the correct bytes. In case of unaligned writes, it will write byte by byte.

@nmoinvaz nmoinvaz added the Architecture Architecture specific label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture Architecture specific
Projects
None yet
Development

No branches or pull requests

3 participants