[PATCH] D119378: [OMPIRBuilder] Remove the support for floating point values for atomic compare operation
Shilei Tian via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 9 14:57:10 PST 2022
tianshilei1992 created this revision.
Herald added a subscriber: hiraditya.
tianshilei1992 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch removes the type punning in atomic compare operation for
floating point values because the direct comparison doesn't make too much sense
for floating point values.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119378
Files:
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===================================================================
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -3481,26 +3481,16 @@
assert(X.Var->getType()->isPointerTy() &&
"OMP atomic expects a pointer to target memory");
- assert((X.ElemTy->isFloatingPointTy() || X.ElemTy->isIntegerTy() ||
- X.ElemTy->isPointerTy()) &&
- "OMP atomic compare expected a scalar type");
+ assert((X.ElemTy->isIntegerTy() || X.ElemTy->isPointerTy()) &&
+ "OMP atomic compare expected a integer scalar type");
if (Op == OMPAtomicCompareOp::EQ) {
- unsigned Addrspace = cast<PointerType>(X.Var->getType())->getAddressSpace();
- IntegerType *IntCastTy =
- IntegerType::get(M.getContext(), X.ElemTy->getScalarSizeInBits());
- Value *XAddr =
- X.ElemTy->isIntegerTy()
- ? X.Var
- : Builder.CreateBitCast(X.Var, IntCastTy->getPointerTo(Addrspace));
AtomicOrdering Failure = AtomicCmpXchgInst::getStrongestFailureOrdering(AO);
// We don't need the result for now.
- (void)Builder.CreateAtomicCmpXchg(XAddr, E, D, MaybeAlign(), AO, Failure);
+ (void)Builder.CreateAtomicCmpXchg(X.Var, E, D, MaybeAlign(), AO, Failure);
} else {
assert((Op == OMPAtomicCompareOp::MAX || Op == OMPAtomicCompareOp::MIN) &&
"Op should be either max or min at this point");
- assert(X.ElemTy->isIntegerTy() &&
- "max and min operators only support integer type");
// Reverse the ordop as the OpenMP forms are different from LLVM forms.
// Let's take max as example.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119378.407315.patch
Type: text/x-patch
Size: 1674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220209/478a6fd4/attachment.bin>
More information about the llvm-commits
mailing list