Skip to content

Document that atomic::fetch_add with unused result must generates ldadd with non-zero output register on Arm with LSE #69503

@gonzalobg

Description

@gonzalobg

The following code:

void inc(std::atomic<uint32_t>* p) {
    p->fetch_add(1, std::memory_order_relaxed);
}

discards the result of the atomic rmw add operation.

On Arm, it generates an ldadd instruction, but I'd expect it to generate an stadd instead, since the result is not used.
See https://gcc.godbolt.org/z/7K5YYEjT9

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions