@@ -27108,9 +27108,6 @@ AArch64TargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const {
27108
27108
unsigned Size = AI->getType()->getPrimitiveSizeInBits();
27109
27109
assert(Size <= 128 && "AtomicExpandPass should've handled larger sizes.");
27110
27110
27111
- if (AI->isFloatingPointOperation())
27112
- return AtomicExpansionKind::CmpXChg;
27113
-
27114
27111
bool CanUseLSE128 = Subtarget->hasLSE128() && Size == 128 &&
27115
27112
(AI->getOperation() == AtomicRMWInst::Xchg ||
27116
27113
AI->getOperation() == AtomicRMWInst::Or ||
@@ -27120,7 +27117,8 @@ AArch64TargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const {
27120
27117
27121
27118
// Nand is not supported in LSE.
27122
27119
// Leave 128 bits to LLSC or CmpXChg.
27123
- if (AI->getOperation() != AtomicRMWInst::Nand && Size < 128) {
27120
+ if (AI->getOperation() != AtomicRMWInst::Nand && Size < 128 &&
27121
+ !AI->isFloatingPointOperation()) {
27124
27122
if (Subtarget->hasLSE())
27125
27123
return AtomicExpansionKind::None;
27126
27124
if (Subtarget->outlineAtomics()) {
@@ -27193,10 +27191,14 @@ Value *AArch64TargetLowering::emitLoadLinked(IRBuilderBase &Builder,
27193
27191
27194
27192
Value *Lo = Builder.CreateExtractValue(LoHi, 0, "lo");
27195
27193
Value *Hi = Builder.CreateExtractValue(LoHi, 1, "hi");
27196
- Lo = Builder.CreateZExt(Lo, ValueTy, "lo64");
27197
- Hi = Builder.CreateZExt(Hi, ValueTy, "hi64");
27198
- return Builder.CreateOr(
27199
- Lo, Builder.CreateShl(Hi, ConstantInt::get(ValueTy, 64)), "val64");
27194
+
27195
+ auto *Int128Ty = Type::getInt128Ty(Builder.getContext());
27196
+ Lo = Builder.CreateZExt(Lo, Int128Ty, "lo64");
27197
+ Hi = Builder.CreateZExt(Hi, Int128Ty, "hi64");
27198
+
27199
+ Value *Or = Builder.CreateOr(
27200
+ Lo, Builder.CreateShl(Hi, ConstantInt::get(Int128Ty, 64)), "val64");
27201
+ return Builder.CreateBitCast(Or, ValueTy);
27200
27202
}
27201
27203
27202
27204
Type *Tys[] = { Addr->getType() };
@@ -27207,8 +27209,8 @@ Value *AArch64TargetLowering::emitLoadLinked(IRBuilderBase &Builder,
27207
27209
const DataLayout &DL = M->getDataLayout();
27208
27210
IntegerType *IntEltTy = Builder.getIntNTy(DL.getTypeSizeInBits(ValueTy));
27209
27211
CallInst *CI = Builder.CreateCall(Ldxr, Addr);
27210
- CI->addParamAttr(
27211
- 0, Attribute::get(Builder.getContext(), Attribute::ElementType, ValueTy ));
27212
+ CI->addParamAttr(0, Attribute::get(Builder.getContext(),
27213
+ Attribute::ElementType, IntEltTy ));
27212
27214
Value *Trunc = Builder.CreateTrunc(CI, IntEltTy);
27213
27215
27214
27216
return Builder.CreateBitCast(Trunc, ValueTy);
@@ -27234,9 +27236,13 @@ Value *AArch64TargetLowering::emitStoreConditional(IRBuilderBase &Builder,
27234
27236
IsRelease ? Intrinsic::aarch64_stlxp : Intrinsic::aarch64_stxp;
27235
27237
Function *Stxr = Intrinsic::getDeclaration(M, Int);
27236
27238
Type *Int64Ty = Type::getInt64Ty(M->getContext());
27239
+ Type *Int128Ty = Type::getInt128Ty(M->getContext());
27240
+
27241
+ Value *CastVal = Builder.CreateBitCast(Val, Int128Ty);
27237
27242
27238
- Value *Lo = Builder.CreateTrunc(Val, Int64Ty, "lo");
27239
- Value *Hi = Builder.CreateTrunc(Builder.CreateLShr(Val, 64), Int64Ty, "hi");
27243
+ Value *Lo = Builder.CreateTrunc(CastVal, Int64Ty, "lo");
27244
+ Value *Hi =
27245
+ Builder.CreateTrunc(Builder.CreateLShr(CastVal, 64), Int64Ty, "hi");
27240
27246
return Builder.CreateCall(Stxr, {Lo, Hi, Addr});
27241
27247
}
27242
27248
0 commit comments