[llvm] 34e8f00 - Attributor: Propagate align to cmpxchg instructions (#134838)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 8 08:15:54 PDT 2025
Author: Matt Arsenault
Date: 2025-04-08T22:15:50+07:00
New Revision: 34e8f00066ee82cba63808e381eaaae89c1b1c79
URL: https://github.com/llvm/llvm-project/commit/34e8f00066ee82cba63808e381eaaae89c1b1c79
DIFF: https://github.com/llvm/llvm-project/commit/34e8f00066ee82cba63808e381eaaae89c1b1c79.diff
LOG: Attributor: Propagate align to cmpxchg instructions (#134838)
Fixes #134480
Added:
Modified:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/test/Transforms/Attributor/align-atomic.ll
Removed:
################################################################################
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]]
;
More information about the llvm-commits
mailing list