[llvm] 04d450f - AtomicExpand: Preserve metadata when bitcasting fp atomicrmw xchg (#115240)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 13 12:51:22 PST 2024
Author: Matt Arsenault
Date: 2024-11-13T12:51:18-08:00
New Revision: 04d450fd8d4e8fcf0b0c5019d9233a5c7d7fe751
URL: https://github.com/llvm/llvm-project/commit/04d450fd8d4e8fcf0b0c5019d9233a5c7d7fe751
DIFF: https://github.com/llvm/llvm-project/commit/04d450fd8d4e8fcf0b0c5019d9233a5c7d7fe751.diff
LOG: AtomicExpand: Preserve metadata when bitcasting fp atomicrmw xchg (#115240)
Added:
Modified:
llvm/lib/CodeGen/AtomicExpandPass.cpp
llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-fp.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp b/llvm/lib/CodeGen/AtomicExpandPass.cpp
index 8d2099b3f8c6c0..a75fa688d87a8d 100644
--- a/llvm/lib/CodeGen/AtomicExpandPass.cpp
+++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp
@@ -496,6 +496,7 @@ AtomicExpandImpl::convertAtomicXchgToIntegerType(AtomicRMWInst *RMWI) {
RMWI->getAlign(), RMWI->getOrdering(),
RMWI->getSyncScopeID());
NewRMWI->setVolatile(RMWI->isVolatile());
+ copyMetadataForAtomic(*NewRMWI, *RMWI);
LLVM_DEBUG(dbgs() << "Replaced " << *RMWI << " with " << *NewRMWI << "\n");
Value *NewRVal = RMWI->getType()->isPointerTy()
diff --git a/llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-fp.ll b/llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-fp.ll
index c88671e3bb407f..2341eb05c568c2 100644
--- a/llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-fp.ll
+++ b/llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-fp.ll
@@ -36,3 +36,25 @@ define double @atomic_xchg_f64_as1(ptr addrspace(1) %ptr) nounwind {
%result = atomicrmw xchg ptr addrspace(1) %ptr, double 4.0 seq_cst
ret double %result
}
+
+define double @atomic_xchg_f64_preserve_md(ptr %ptr) nounwind {
+; CHECK-LABEL: @atomic_xchg_f64_preserve_md(
+; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr [[PTR:%.*]], align 8, !mmra [[META0:![0-9]+]]
+; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
+; CHECK: atomicrmw.start:
+; CHECK-NEXT: [[LOADED:%.*]] = phi i64 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
+; CHECK-NEXT: [[TMP2:%.*]] = cmpxchg ptr [[PTR]], i64 [[LOADED]], i64 4616189618054758400 seq_cst seq_cst, align 8, !mmra [[META0]]
+; CHECK-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP2]], 1
+; CHECK-NEXT: [[NEWLOADED]] = extractvalue { i64, i1 } [[TMP2]], 0
+; CHECK-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
+; CHECK: atomicrmw.end:
+; CHECK-NEXT: [[TMP3:%.*]] = bitcast i64 [[NEWLOADED]] to double
+; CHECK-NEXT: ret double [[TMP3]]
+;
+ %result = atomicrmw xchg ptr %ptr, double 4.000000e+00 seq_cst, align 8, !mmra !0
+ ret double %result
+}
+
+!0 = !{!1, !2}
+!1 = !{!"foo", !"bar"}
+!2 = !{!"bux", !"baz"}
More information about the llvm-commits
mailing list