================
@@ -11810,14 +11810,98 @@ OpenMPIRBuilder::InsertPointTy
OpenMPIRBuilder::createAtomicCompare(
}
bool IsInteger = E->getType()->isIntegerTy();
+ // x86_fp80 holds 80 value bits in 16 bytes; the padding must not take part
+ // in the comparison.
+ const DataLayout &DL = M.getDataLayout();
+ bool HasPadding = X.ElemTy->isFloatingPointTy() &&
+ X.ElemTy->getPrimitiveSizeInBits().getFixedValue() !=
+ DL.getTypeAllocSizeInBits(X.ElemTy).getFixedValue();
if (Op == OMPAtomicCompareOp::EQ) {
// OldValue and SuccessOrFail are set below and used in the shared V.Var /
// R.Var handling.
Value *OldValue = nullptr;
Value *SuccessOrFail = nullptr;
- if (!IsInteger && HandleFPNegZero) {
+ if (HasPadding) {
+ // Load x, compare its value bits only, and use the loaded pattern as the
+ // expected value of the cmpxchg; retry if x changed in between.
+ assert(DL.isLittleEndian() && "padded FP type on a big-endian target");
+ LLVMContext &Ctx = M.getContext();
+ IntegerType *IntCastTy = IntegerType::get(
+ Ctx, DL.getTypeAllocSizeInBits(X.ElemTy).getFixedValue());
+ IntegerType *ValueIntTy = IntegerType::get(
+ Ctx, X.ElemTy->getPrimitiveSizeInBits().getFixedValue());
+ Value *EBits = Builder.CreateBitCast(E, ValueIntTy);
+ Value *DInt =
+ Builder.CreateZExt(Builder.CreateBitCast(D, ValueIntTy), IntCastTy);
+
+ LoadInst *XLoad = Builder.CreateAlignedLoad(
----------------
akash-manna-sky wrote:
Done. Both loads take X.IsVolatile and every cmpxchg and atomicrmw in
createAtomicCompare calls setVolatile(X.IsVolatile). Added @x_volatile (load
atomic volatile + cmpxchg volatile), @x_volatile_double and @x_volatile_min;
the padded unit test also uses a volatile x.
https://github.com/llvm/llvm-project/pull/226567
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits