[llvm-branch-commits] [llvm] [AtomicExpand] Add bitcasts when expanding load atomic vector (PR #120716)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu May 1 01:08:44 PDT 2025
================
@@ -2066,9 +2066,23 @@ 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
+ if (I->getType()->getScalarType()->isPointerTy() &&
+ I->getType()->isVectorTy() && !Result->getType()->isVectorTy()) {
+ unsigned AS =
+ cast<PointerType>(I->getType()->getScalarType())->getAddressSpace();
+ ElementCount EC = cast<VectorType>(I->getType())->getElementCount();
+ Value *BC = Builder.CreateBitCast(
+ Result,
+ VectorType::get(IntegerType::get(Ctx, DL.getPointerSizeInBits(AS)),
+ EC));
+ Value *IntToPtr = Builder.CreateIntToPtr(
+ BC, VectorType::get(PointerType::get(Ctx, AS), EC));
+ V = Builder.CreateBitOrPointerCast(IntToPtr, I->getType());
----------------
arsenm wrote:
This final CreateBitOrPointerCast is a no-op?
https://github.com/llvm/llvm-project/pull/120716
More information about the llvm-branch-commits
mailing list