[llvm-branch-commits] [llvm] AMDGPU: Preserve atomicrmw name when specializing address space (PR #102470)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 8 07:03:06 PDT 2024
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/102470
None
>From 01182f305e400b890a5829f6da78b01a2968adaa Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 8 Aug 2024 18:02:11 +0400
Subject: [PATCH] AMDGPU: Preserve atomicrmw name when specializing address
space
---
llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 3 ++-
...tomic-rmw-fadd-flat-specialization-preserve-name.ll | 10 ++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-rmw-fadd-flat-specialization-preserve-name.ll
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index e982f1e643289..7735833b1ad2c 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -16654,12 +16654,13 @@ void SITargetLowering::emitExpandAtomicRMW(AtomicRMWInst *AI) const {
Builder.CreateBr(PhiBB);
Builder.SetInsertPoint(PhiBB);
- PHINode *Loaded = Builder.CreatePHI(ValTy, 3, "loaded.phi");
+ PHINode *Loaded = Builder.CreatePHI(ValTy, 3);
Loaded->addIncoming(LoadedShared, SharedBB);
Loaded->addIncoming(LoadedPrivate, PrivateBB);
Loaded->addIncoming(LoadedGlobal, GlobalBB);
Builder.CreateBr(ExitBB);
+ Loaded->takeName(AI);
AI->replaceAllUsesWith(Loaded);
AI->eraseFromParent();
}
diff --git a/llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-rmw-fadd-flat-specialization-preserve-name.ll b/llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-rmw-fadd-flat-specialization-preserve-name.ll
new file mode 100644
index 0000000000000..44cd7097059cd
--- /dev/null
+++ b/llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-rmw-fadd-flat-specialization-preserve-name.ll
@@ -0,0 +1,10 @@
+; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -passes=atomic-expand %s | FileCheck %s
+
+; CHECK: %preserve_me = phi float [ %{{[0-9]+}}, %atomicrmw.shared ], [ %loaded.private, %atomicrmw.private ], [ %{{[0-9]+}}, %atomicrmw.global ]
+; CHECK: ret float %preserve_me
+define float @expand_preserve_name(ptr %addr, float %val) {
+ %preserve_me = atomicrmw fadd ptr %addr, float %val seq_cst, !amdgpu.no.fine.grained.memory !0, !amdgpu.ignore.denormal.mode !0
+ ret float %preserve_me
+}
+
+!0 = !{}
More information about the llvm-branch-commits
mailing list