@@ -27079,9 +27079,6 @@ AArch64TargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const {
27079
27079
unsigned Size = AI->getType()->getPrimitiveSizeInBits();
27080
27080
assert(Size <= 128 && "AtomicExpandPass should've handled larger sizes.");
27081
27081
27082
- if (AI->isFloatingPointOperation())
27083
- return AtomicExpansionKind::CmpXChg;
27084
-
27085
27082
bool CanUseLSE128 = Subtarget->hasLSE128() && Size == 128 &&
27086
27083
(AI->getOperation() == AtomicRMWInst::Xchg ||
27087
27084
AI->getOperation() == AtomicRMWInst::Or ||
@@ -27091,7 +27088,8 @@ AArch64TargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const {
27091
27088
27092
27089
// Nand is not supported in LSE.
27093
27090
// Leave 128 bits to LLSC or CmpXChg.
27094
- if (AI->getOperation() != AtomicRMWInst::Nand && Size < 128) {
27091
+ if (AI->getOperation() != AtomicRMWInst::Nand && Size < 128 &&
27092
+ !AI->isFloatingPointOperation()) {
27095
27093
if (Subtarget->hasLSE())
27096
27094
return AtomicExpansionKind::None;
27097
27095
if (Subtarget->outlineAtomics()) {
@@ -27164,10 +27162,14 @@ Value *AArch64TargetLowering::emitLoadLinked(IRBuilderBase &Builder,
27164
27162
27165
27163
Value *Lo = Builder.CreateExtractValue(LoHi, 0, "lo");
27166
27164
Value *Hi = Builder.CreateExtractValue(LoHi, 1, "hi");
27167
- Lo = Builder.CreateZExt(Lo, ValueTy, "lo64");
27168
- Hi = Builder.CreateZExt(Hi, ValueTy, "hi64");
27169
- return Builder.CreateOr(
27170
- Lo, Builder.CreateShl(Hi, ConstantInt::get(ValueTy, 64)), "val64");
27165
+
27166
+ auto *Int128Ty = Type::getInt128Ty(Builder.getContext());
27167
+ Lo = Builder.CreateZExt(Lo, Int128Ty, "lo64");
27168
+ Hi = Builder.CreateZExt(Hi, Int128Ty, "hi64");
27169
+
27170
+ Value *Or = Builder.CreateOr(
27171
+ Lo, Builder.CreateShl(Hi, ConstantInt::get(Int128Ty, 64)), "val64");
27172
+ return Builder.CreateBitCast(Or, ValueTy);
27171
27173
}
27172
27174
27173
27175
Type *Tys[] = { Addr->getType() };
@@ -27178,8 +27180,8 @@ Value *AArch64TargetLowering::emitLoadLinked(IRBuilderBase &Builder,
27178
27180
const DataLayout &DL = M->getDataLayout();
27179
27181
IntegerType *IntEltTy = Builder.getIntNTy(DL.getTypeSizeInBits(ValueTy));
27180
27182
CallInst *CI = Builder.CreateCall(Ldxr, Addr);
27181
- CI->addParamAttr(
27182
- 0, Attribute::get(Builder.getContext(), Attribute::ElementType, ValueTy ));
27183
+ CI->addParamAttr(0, Attribute::get(Builder.getContext(),
27184
+ Attribute::ElementType, IntEltTy ));
27183
27185
Value *Trunc = Builder.CreateTrunc(CI, IntEltTy);
27184
27186
27185
27187
return Builder.CreateBitCast(Trunc, ValueTy);
@@ -27205,9 +27207,13 @@ Value *AArch64TargetLowering::emitStoreConditional(IRBuilderBase &Builder,
27205
27207
IsRelease ? Intrinsic::aarch64_stlxp : Intrinsic::aarch64_stxp;
27206
27208
Function *Stxr = Intrinsic::getDeclaration(M, Int);
27207
27209
Type *Int64Ty = Type::getInt64Ty(M->getContext());
27210
+ Type *Int128Ty = Type::getInt128Ty(M->getContext());
27211
+
27212
+ Value *CastVal = Builder.CreateBitCast(Val, Int128Ty);
27208
27213
27209
- Value *Lo = Builder.CreateTrunc(Val, Int64Ty, "lo");
27210
- Value *Hi = Builder.CreateTrunc(Builder.CreateLShr(Val, 64), Int64Ty, "hi");
27214
+ Value *Lo = Builder.CreateTrunc(CastVal, Int64Ty, "lo");
27215
+ Value *Hi =
27216
+ Builder.CreateTrunc(Builder.CreateLShr(CastVal, 64), Int64Ty, "hi");
27211
27217
return Builder.CreateCall(Stxr, {Lo, Hi, Addr});
27212
27218
}
27213
27219
0 commit comments