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

[SystemZ] Enable AtomicExpand pass #70398

Merged
merged 1 commit into from
Oct 31, 2023
Merged

Conversation

iii-i
Copy link
Member

@iii-i iii-i commented Oct 27, 2023

The upcoming OpenMP support for SystemZ requires handling of IR insns like atomicrmw fadd. Normally atomic float operations are expanded by Clang and such insns do not occur, but OpenMP generates them directly. Other architectures handle this using the AtomicExpand pass, which SystemZ did not need so far. Enable it.

Currently AtomicExpand treats atomic load and stores of floats pessimistically: it casts them to integers, which SystemZ does not need, since the floating point load and store instructions are already atomic. However, the way Clang currently expands them is pessimistic as well, so this change does not make things worse. Optimizing operations on atomic floats can be a separate change in the future.

This change does not create any differences the Linux kernel build.

@iii-i iii-i requested a review from uweigand October 27, 2023 01:06
@uweigand
Copy link
Member

Thanks, this looks good to me. Could you also add test cases for the newly-supported operations? Along the lines of the existing tests in llvm/test/CodeGen/SystemZ/atomicrmw-*, but for fadd/fsub/fmin/fmax and potentially uinc_wrap/udec_wrap. Also, maybe add variants of the atomic-load/store-* and atomicrmw-xchg-* tests for floating-point types.

The upcoming OpenMP support for SystemZ requires handling of IR insns
like `atomicrmw fadd`. Normally atomic float operations are expanded
by Clang and such insns do not occur, but OpenMP generates them
directly. Other architectures handle this using the AtomicExpand pass,
which SystemZ did not need so far. Enable it; implement atomicrmw
sub-operations uinc_wrap and udec_wrap by expanding them to a
compare-and-swap loop; add tests.

Currently AtomicExpand treats atomic load and stores of floats
pessimistically: it casts them to integers, which SystemZ does not
need, since the floating point load and store instructions are already
atomic. However, the way Clang currently expands them is pessimistic
as well, so this change does not make things worse. Optimizing
operations on atomic floats can be a separate change in the future.

This change does not create any differences the Linux kernel build.
@iii-i
Copy link
Member Author

iii-i commented Oct 30, 2023

  • Implement UIncWrap and UDecWrap; add a number of tests.

Copy link
Member

@uweigand uweigand left a comment

Choose a reason for hiding this comment

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

Some of these sequences could probably be improved a bit, but that certainly can be done separately. This patch LGTM, thanks!

@uweigand uweigand merged commit 03934e7 into llvm:main Oct 31, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants