Skip to content

[AMDGPU] Support double type in atomic optimizer. #84307

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
merged 4 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ void AMDGPUAtomicOptimizerImpl::visitAtomicRMWInst(AtomicRMWInst &I) {
break;
}

// Only 32-bit floating point atomic ops are supported.
if (AtomicRMWInst::isFPOperation(Op) && !I.getType()->isFloatTy()) {
// Only 32 and 64 bit floating point atomic ops are supported.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should really handle f16 too, in a separate patch

if (AtomicRMWInst::isFPOperation(Op) &&
!(I.getType()->isFloatTy() || I.getType()->isDoubleTy())) {
return;
}

Expand Down Expand Up @@ -920,8 +921,10 @@ void AMDGPUAtomicOptimizerImpl::optimizeAtomic(Instruction &I,
Value *BroadcastI = nullptr;

if (TyBitWidth == 64) {
Value *const ExtractLo = B.CreateTrunc(PHI, Int32Ty);
Value *const ExtractHi = B.CreateTrunc(B.CreateLShr(PHI, 32), Int32Ty);
Value *CastedPhi = B.CreateBitCast(PHI, IntNTy);
Value *const ExtractLo = B.CreateTrunc(CastedPhi, Int32Ty);
Value *const ExtractHi =
B.CreateTrunc(B.CreateLShr(CastedPhi, 32), Int32Ty);
CallInst *const ReadFirstLaneLo =
B.CreateIntrinsic(Intrinsic::amdgcn_readfirstlane, {}, ExtractLo);
CallInst *const ReadFirstLaneHi =
Expand Down
274 changes: 223 additions & 51 deletions llvm/test/CodeGen/AMDGPU/GlobalISel/fp64-atomics-gfx90a.ll

Large diffs are not rendered by default.

270 changes: 213 additions & 57 deletions llvm/test/CodeGen/AMDGPU/fp64-atomics-gfx90a.ll

Large diffs are not rendered by default.

560 changes: 560 additions & 0 deletions llvm/test/CodeGen/AMDGPU/global_atomic_optimizer_fp_rtn.ll

Large diffs are not rendered by default.

420 changes: 420 additions & 0 deletions llvm/test/CodeGen/AMDGPU/global_atomics_optimizer_fp_no_rtn.ll

Large diffs are not rendered by default.

5,578 changes: 5,578 additions & 0 deletions llvm/test/CodeGen/AMDGPU/global_atomics_scan_fadd.ll

Large diffs are not rendered by default.

3,960 changes: 3,960 additions & 0 deletions llvm/test/CodeGen/AMDGPU/global_atomics_scan_fmax.ll

Large diffs are not rendered by default.

3,960 changes: 3,960 additions & 0 deletions llvm/test/CodeGen/AMDGPU/global_atomics_scan_fmin.ll

Large diffs are not rendered by default.

5,576 changes: 5,576 additions & 0 deletions llvm/test/CodeGen/AMDGPU/global_atomics_scan_fsub.ll

Large diffs are not rendered by default.