diff options
author | jofrn <jofernau@amd.com> | 2024-12-20 06:14:28 -0500 |
---|---|---|
committer | jofrn <jofernau@amd.com> | 2025-06-02 00:15:05 -0400 |
commit | 70a2b52ffeae81869323a0874c51a7947ec2fe71 (patch) | |
tree | 2dad38223ba86f39386c2ccee9c08e766d7d341c /llvm/lib/CodeGen/AtomicExpandPass.cpp | |
parent | 6eb10b5af424ebb18d4e30a4bbfaf8f304e68f60 (diff) | |
download | llvm-users/jofrn/atomicvec-stack2.zip llvm-users/jofrn/atomicvec-stack2.tar.gz llvm-users/jofrn/atomicvec-stack2.tar.bz2 |
[AtomicExpand] Add bitcasts when expanding load atomic vectorusers/jofrn/spr/main/f430c1afusers/jofrn/atomicvec-stack3users/jofrn/atomicvec-stack2
AtomicExpand fails for aligned `load atomic <n x T>` because it
does not find a compatible library call. This change adds appropriate
bitcasts so that the call can be lowered. It also adds support for
128 bit lowering in tablegen to support SSE/AVX.
commit-id:f430c1af
Diffstat (limited to 'llvm/lib/CodeGen/AtomicExpandPass.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AtomicExpandPass.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp b/llvm/lib/CodeGen/AtomicExpandPass.cpp index c376de8..70f59ea 100644 --- a/llvm/lib/CodeGen/AtomicExpandPass.cpp +++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp @@ -2066,9 +2066,18 @@ bool AtomicExpandImpl::expandAtomicOpToLibcall( I->replaceAllUsesWith(V); } else if (HasResult) { Value *V; - if (UseSizedLibcall) - V = Builder.CreateBitOrPointerCast(Result, I->getType()); - else { + if (UseSizedLibcall) { + // Add bitcasts from Result's scalar type to I's <n x ptr> vector type + auto *PtrTy = dyn_cast<PointerType>(I->getType()->getScalarType()); + auto *VTy = dyn_cast<VectorType>(I->getType()); + if (VTy && PtrTy && !Result->getType()->isVectorTy()) { + unsigned AS = PtrTy->getAddressSpace(); + Value *BC = Builder.CreateBitCast( + Result, VTy->getWithNewType(DL.getIntPtrType(Ctx, AS))); + V = Builder.CreateIntToPtr(BC, I->getType()); + } else + V = Builder.CreateBitOrPointerCast(Result, I->getType()); + } else { V = Builder.CreateAlignedLoad(I->getType(), AllocaResult, AllocaAlignment); Builder.CreateLifetimeEnd(AllocaResult, SizeVal64); |