================ @@ -6033,6 +6034,52 @@ std::pair<Value *, Value *> OpenMPIRBuilder::emitAtomicUpdate( Res.second = Res.first; else Res.second = emitRMWOpAsInstruction(Res.first, Expr, RMWOp); + } else if (RMWOp == llvm::AtomicRMWInst::BinOp::BAD_BINOP) { + LoadInst *OldVal = + Builder.CreateLoad(XElemTy, X, X->getName() + ".atomic.load"); + OldVal->setAtomic(AO); + const DataLayout &LoadDL = OldVal->getModule()->getDataLayout(); + unsigned LoadSize = + LoadDL.getTypeStoreSize(OldVal->getPointerOperand()->getType()); + OpenMPIRBuilder::AtomicInfo atomicInfo(&Builder, XElemTy, LoadSize * 8, + LoadSize * 8, OldVal->getAlign(), + OldVal->getAlign(), true, X); + auto AtomicLoadRes = atomicInfo.EmitAtomicLoadLibcall(AO); + BasicBlock *CurBB = Builder.GetInsertBlock(); + Instruction *CurBBTI = CurBB->getTerminator(); + CurBBTI = CurBBTI ? CurBBTI : Builder.CreateUnreachable(); + BasicBlock *ExitBB = + CurBB->splitBasicBlock(CurBBTI, X->getName() + ".atomic.exit"); + BasicBlock *ContBB = CurBB->splitBasicBlock(CurBB->getTerminator(), + X->getName() + ".atomic.cont"); + ContBB->getTerminator()->eraseFromParent(); + Builder.restoreIP(AllocaIP); + AllocaInst *NewAtomicAddr = Builder.CreateAlloca(XElemTy); + NewAtomicAddr->setName(X->getName() + "x.new.val"); + Builder.SetInsertPoint(ContBB); + llvm::PHINode *PHI = Builder.CreatePHI(OldVal->getType(), 2); + PHI->addIncoming(AtomicLoadRes.first, CurBB); + Value *OldExprVal = PHI; + Value *Upd = UpdateOp(OldExprVal, Builder); + Builder.CreateStore(Upd, NewAtomicAddr); + AtomicOrdering Failure = + llvm::AtomicCmpXchgInst::getStrongestFailureOrdering(AO); + auto Result = atomicInfo.EmitAtomicCompareExchangeLibcall( ---------------- Meinersbur wrote:
```suggestion auto Result = atomicInfo.EmitAtomicCompareExchange( ``` The decision of whether to to use libcall should be made by AtomicInfo itself. https://github.com/llvm/llvm-project/pull/92364 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits