[llvm] 59f91dd - [InstCombine] Preserve alignment in atomicrmw -> store fold
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 9 06:37:31 PST 2023
Author: Nikita Popov
Date: 2023-01-09T15:37:24+01:00
New Revision: 59f91ddf90d470e113f9322314ce7c36e21ff0b3
URL: https://github.com/llvm/llvm-project/commit/59f91ddf90d470e113f9322314ce7c36e21ff0b3
DIFF: https://github.com/llvm/llvm-project/commit/59f91ddf90d470e113f9322314ce7c36e21ff0b3.diff
LOG: [InstCombine] Preserve alignment in atomicrmw -> store fold
Preserve the alignment of the original atomicrmw, rather than using
the ABI alignment.
The same problem exists for loads, but that code is being removed
in D141277 anyway.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp
llvm/test/Transforms/InstCombine/atomicrmw.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp
index 0327efbf9614..06d8fb2d474d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp
@@ -128,10 +128,9 @@ Instruction *InstCombinerImpl::visitAtomicRMWInst(AtomicRMWInst &RMWI) {
if (Ordering != AtomicOrdering::Release &&
Ordering != AtomicOrdering::Monotonic)
return nullptr;
- auto *SI = new StoreInst(RMWI.getValOperand(),
- RMWI.getPointerOperand(), &RMWI);
- SI->setAtomic(Ordering, RMWI.getSyncScopeID());
- SI->setAlignment(DL.getABITypeAlign(RMWI.getType()));
+ new StoreInst(RMWI.getValOperand(), RMWI.getPointerOperand(),
+ /*isVolatile*/ false, RMWI.getAlign(), Ordering,
+ RMWI.getSyncScopeID(), &RMWI);
return eraseInstFromFunction(RMWI);
}
diff --git a/llvm/test/Transforms/InstCombine/atomicrmw.ll b/llvm/test/Transforms/InstCombine/atomicrmw.ll
index b8349196bf0e..7da822b00a63 100644
--- a/llvm/test/Transforms/InstCombine/atomicrmw.ll
+++ b/llvm/test/Transforms/InstCombine/atomicrmw.ll
@@ -289,7 +289,7 @@ define void @xchg_unused_release(ptr %addr) {
define void @xchg_unused_under_aligned(ptr %addr) {
; CHECK-LABEL: @xchg_unused_under_aligned(
-; CHECK-NEXT: store atomic i32 -1, ptr [[ADDR:%.*]] release, align 4
+; CHECK-NEXT: store atomic i32 -1, ptr [[ADDR:%.*]] release, align 1
; CHECK-NEXT: ret void
;
atomicrmw xchg ptr %addr, i32 -1 release, align 1
@@ -298,7 +298,7 @@ define void @xchg_unused_under_aligned(ptr %addr) {
define void @xchg_unused_over_aligned(ptr %addr) {
; CHECK-LABEL: @xchg_unused_over_aligned(
-; CHECK-NEXT: store atomic i32 -1, ptr [[ADDR:%.*]] release, align 4
+; CHECK-NEXT: store atomic i32 -1, ptr [[ADDR:%.*]] release, align 8
; CHECK-NEXT: ret void
;
atomicrmw xchg ptr %addr, i32 -1 release, align 8
More information about the llvm-commits
mailing list