-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[AtomicExpand] Add bitcasts when expanding load atomic vector #120716
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
base: users/jofrn/spr/main/80b9b6a7
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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()) { | ||||||
Comment on lines
+2071
to
+2073
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should probably be a utility for this somewhere |
||||||
unsigned AS = PtrTy->getAddressSpace(); | ||||||
Value *BC = Builder.CreateBitCast( | ||||||
Result, VTy->getWithNewType(DL.getIntPtrType(Ctx, AS))); | ||||||
V = Builder.CreateIntToPtr(BC, I->getType()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} else | ||||||
V = Builder.CreateBitOrPointerCast(Result, I->getType()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} else { | ||||||
V = Builder.CreateAlignedLoad(I->getType(), AllocaResult, | ||||||
AllocaAlignment); | ||||||
Builder.CreateLifetimeEnd(AllocaResult, SizeVal64); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1211,6 +1211,11 @@ def : Pat<(v4i32 (scalar_to_vector (i32 (atomic_load_32 addr:$src)))), | |
def : Pat<(v2i64 (scalar_to_vector (i64 (atomic_load_64 addr:$src)))), | ||
(MOV64toPQIrm addr:$src)>; // load atomic <2 x i32,float> | ||
|
||
def : Pat<(v2i64 (atomic_load_128_v2i64 addr:$src)), | ||
(VMOVAPDrm addr:$src)>; // load atomic <2 x i64> | ||
def : Pat<(v4i32 (atomic_load_128_v4i32 addr:$src)), | ||
(VMOVAPDrm addr:$src)>; // load atomic <4 x i32> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are required for 128 bit vectors in SSE/AVX. The tests added in this PR require both the AtomicExpand change and these td records. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These require AVX/AVX512 variants (see below) - but x86 doesn't guarantee atomics for anything above 8 bytes (and those must be aligned to avoid cacheline crossing). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think all known AVX capable x86 targets allow 16 byte aligned atomics, its not official but we assume it in X86TargetLowering::shouldExpandAtomicLoadInIR |
||
|
||
// Floating point loads/stores. | ||
def : Pat<(atomic_store_32 (i32 (bitconvert (f32 FR32:$src))), addr:$dst), | ||
(MOVSSmr addr:$dst, FR32:$src)>, Requires<[UseSSE1]>; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch should not require adding this, or touching any of the backend patterns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests that use them must also have the changes from AtomicExpand.