-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Attributor: Propagate align to cmpxchg instructions #134838
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
Merged
arsenm
merged 1 commit into
main
from
users/arsenm/attributor/propagate-align-to-cmpxchg-instructions
Apr 8, 2025
Merged
Attributor: Propagate align to cmpxchg instructions #134838
arsenm
merged 1 commit into
main
from
users/arsenm/attributor/propagate-align-to-cmpxchg-instructions
Apr 8, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Apr 8, 2025
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-llvm-transforms Author: Matt Arsenault (arsenm) ChangesFixes #134480 Full diff: https://github.com/llvm/llvm-project/pull/134838.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 717ba7f688548..cc6e846f4f211 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5317,6 +5317,15 @@ struct AAAlignImpl : AAAlign {
InstrChanged = ChangeStatus::CHANGED;
}
}
+ } else if (auto *CAS = dyn_cast<AtomicCmpXchgInst>(U.getUser())) {
+ if (CAS->getPointerOperand() == &AssociatedValue) {
+ if (CAS->getAlign() < getAssumedAlign()) {
+ STATS_DECLTRACK(AAAlign, AtomicCmpXchg,
+ "Number of times alignment added to cmpxchg");
+ CAS->setAlignment(getAssumedAlign());
+ InstrChanged = ChangeStatus::CHANGED;
+ }
+ }
}
}
diff --git a/llvm/test/Transforms/Attributor/align-atomic.ll b/llvm/test/Transforms/Attributor/align-atomic.ll
index 0931c14685a87..0b363741cc168 100644
--- a/llvm/test/Transforms/Attributor/align-atomic.ll
+++ b/llvm/test/Transforms/Attributor/align-atomic.ll
@@ -37,7 +37,7 @@ define ptr @atomicrmw_non_ptr_op_no_propagate(ptr %ptr, ptr align 16 %val) {
define i32 @cmpxchg_propagate(ptr align 8 %ptr, i32 %cmp, i32 %val) {
; CHECK-LABEL: define i32 @cmpxchg_propagate(
; CHECK-SAME: ptr nofree noundef nonnull align 8 captures(none) dereferenceable(4) [[PTR:%.*]], i32 [[CMP:%.*]], i32 [[VAL:%.*]]) #[[ATTR0]] {
-; CHECK-NEXT: [[PAIR:%.*]] = cmpxchg ptr [[PTR]], i32 [[CMP]], i32 [[VAL]] seq_cst monotonic, align 2
+; CHECK-NEXT: [[PAIR:%.*]] = cmpxchg ptr [[PTR]], i32 [[CMP]], i32 [[VAL]] seq_cst monotonic, align 8
; CHECK-NEXT: [[RESULT:%.*]] = extractvalue { i32, i1 } [[PAIR]], 0
; CHECK-NEXT: ret i32 [[RESULT]]
;
|
shiltian
approved these changes
Apr 8, 2025
396afde
to
6fa8d75
Compare
Base automatically changed from
users/arsenm/attributor/propagate-align-to-atomicrmw-instructions
to
main
April 8, 2025 15:12
e945a79
to
4d6890e
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #134480