Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 73f9a1d

Browse files
committed
Revert r351778: IR: Add fp operations to atomicrmw
This broke the RISCV build, and even with that fixed, one of the RISCV tests behaves surprisingly differently with asserts than without, leaving there no clear test pattern to use. Generally it seems bad for hte IR to differ substantially due to asserts (as in, an alloca is used with asserts that isn't needed without!) and nothing I did simply would fix it so I'm reverting back to green. This also required reverting the RISCV build fix in r351782. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351796 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 2447081 commit 73f9a1d

26 files changed

+22
-395
lines changed

docs/LangRef.rst

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8667,18 +8667,15 @@ operation. The operation must be one of the following keywords:
86678667
- min
86688668
- umax
86698669
- umin
8670-
- fadd
8671-
- fsub
86728670

86738671
For most of these operations, the type of '<value>' must be an integer
86748672
type whose bit width is a power of two greater than or equal to eight
86758673
and less than or equal to a target-specific size limit. For xchg, this
86768674
may also be a floating point type with the same size constraints as
8677-
integers. For fadd/fsub, this must be a floating point type. The
8678-
type of the '``<pointer>``' operand must be a pointer to that type. If
8679-
the ``atomicrmw`` is marked as ``volatile``, then the optimizer is not
8680-
allowed to modify the number or order of execution of this
8681-
``atomicrmw`` with other :ref:`volatile operations <volatile>`.
8675+
integers. The type of the '``<pointer>``' operand must be a pointer to
8676+
that type. If the ``atomicrmw`` is marked as ``volatile``, then the
8677+
optimizer is not allowed to modify the number or order of execution of
8678+
this ``atomicrmw`` with other :ref:`volatile operations <volatile>`.
86828679

86838680
A ``atomicrmw`` instruction can also take an optional
86848681
":ref:`syncscope <syncscope>`" argument.
@@ -8704,8 +8701,6 @@ operation argument:
87048701
comparison)
87058702
- umin: ``*ptr = *ptr < val ? *ptr : val`` (using an unsigned
87068703
comparison)
8707-
- fadd: ``*ptr = *ptr + val`` (using floating point arithmetic)
8708-
- fsub: ``*ptr = *ptr - val`` (using floating point arithmetic)
87098704

87108705
Example:
87118706
""""""""

include/llvm/Bitcode/LLVMBitCodes.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,7 @@ enum RMWOperations {
406406
RMW_MAX = 7,
407407
RMW_MIN = 8,
408408
RMW_UMAX = 9,
409-
RMW_UMIN = 10,
410-
RMW_FADD = 11,
411-
RMW_FSUB = 12
409+
RMW_UMIN = 10
412410
};
413411

414412
/// OverflowingBinaryOperatorOptionalFlags - Flags for serializing

include/llvm/CodeGen/TargetLowering.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,9 +1715,8 @@ class TargetLoweringBase {
17151715

17161716
/// Returns how the IR-level AtomicExpand pass should expand the given
17171717
/// AtomicRMW, if at all. Default is to never expand.
1718-
virtual AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
1719-
return RMW->isFloatingPointOperation() ?
1720-
AtomicExpansionKind::CmpXChg : AtomicExpansionKind::None;
1718+
virtual AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *) const {
1719+
return AtomicExpansionKind::None;
17211720
}
17221721

17231722
/// On some platforms, an AtomicRMW that never actually modifies the value

include/llvm/IR/Instructions.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -724,14 +724,8 @@ class AtomicRMWInst : public Instruction {
724724
/// *p = old <unsigned v ? old : v
725725
UMin,
726726

727-
/// *p = old + v
728-
FAdd,
729-
730-
/// *p = old - v
731-
FSub,
732-
733727
FIRST_BINOP = Xchg,
734-
LAST_BINOP = FSub,
728+
LAST_BINOP = UMin,
735729
BAD_BINOP
736730
};
737731

@@ -753,16 +747,6 @@ class AtomicRMWInst : public Instruction {
753747

754748
static StringRef getOperationName(BinOp Op);
755749

756-
static bool isFPOperation(BinOp Op) {
757-
switch (Op) {
758-
case AtomicRMWInst::FAdd:
759-
case AtomicRMWInst::FSub:
760-
return true;
761-
default:
762-
return false;
763-
}
764-
}
765-
766750
void setOperation(BinOp Operation) {
767751
unsigned short SubclassData = getSubclassDataFromInstruction();
768752
setInstructionSubclassData((SubclassData & 31) |
@@ -820,10 +804,6 @@ class AtomicRMWInst : public Instruction {
820804
return getPointerOperand()->getType()->getPointerAddressSpace();
821805
}
822806

823-
bool isFloatingPointOperation() const {
824-
return isFPOperation(getOperation());
825-
}
826-
827807
// Methods for support type inquiry through isa, cast, and dyn_cast:
828808
static bool classof(const Instruction *I) {
829809
return I->getOpcode() == Instruction::AtomicRMW;

lib/AsmParser/LLParser.cpp

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6815,7 +6815,6 @@ int LLParser::ParseAtomicRMW(Instruction *&Inst, PerFunctionState &PFS) {
68156815
AtomicOrdering Ordering = AtomicOrdering::NotAtomic;
68166816
SyncScope::ID SSID = SyncScope::System;
68176817
bool isVolatile = false;
6818-
bool IsFP = false;
68196818
AtomicRMWInst::BinOp Operation;
68206819

68216820
if (EatIfPresent(lltok::kw_volatile))
@@ -6834,14 +6833,6 @@ int LLParser::ParseAtomicRMW(Instruction *&Inst, PerFunctionState &PFS) {
68346833
case lltok::kw_min: Operation = AtomicRMWInst::Min; break;
68356834
case lltok::kw_umax: Operation = AtomicRMWInst::UMax; break;
68366835
case lltok::kw_umin: Operation = AtomicRMWInst::UMin; break;
6837-
case lltok::kw_fadd:
6838-
Operation = AtomicRMWInst::FAdd;
6839-
IsFP = true;
6840-
break;
6841-
case lltok::kw_fsub:
6842-
Operation = AtomicRMWInst::FSub;
6843-
IsFP = true;
6844-
break;
68456836
}
68466837
Lex.Lex(); // Eat the operation.
68476838

@@ -6858,25 +6849,18 @@ int LLParser::ParseAtomicRMW(Instruction *&Inst, PerFunctionState &PFS) {
68586849
if (cast<PointerType>(Ptr->getType())->getElementType() != Val->getType())
68596850
return Error(ValLoc, "atomicrmw value and pointer type do not match");
68606851

6861-
if (Operation == AtomicRMWInst::Xchg) {
6862-
if (!Val->getType()->isIntegerTy() &&
6863-
!Val->getType()->isFloatingPointTy()) {
6864-
return Error(ValLoc, "atomicrmw " +
6865-
AtomicRMWInst::getOperationName(Operation) +
6866-
" operand must be an integer or floating point type");
6867-
}
6868-
} else if (IsFP) {
6869-
if (!Val->getType()->isFloatingPointTy()) {
6870-
return Error(ValLoc, "atomicrmw " +
6871-
AtomicRMWInst::getOperationName(Operation) +
6872-
" operand must be a floating point type");
6873-
}
6874-
} else {
6875-
if (!Val->getType()->isIntegerTy()) {
6876-
return Error(ValLoc, "atomicrmw " +
6877-
AtomicRMWInst::getOperationName(Operation) +
6878-
" operand must be an integer");
6879-
}
6852+
if (Operation != AtomicRMWInst::Xchg && !Val->getType()->isIntegerTy()) {
6853+
return Error(ValLoc, "atomicrmw " +
6854+
AtomicRMWInst::getOperationName(Operation) +
6855+
" operand must be an integer");
6856+
}
6857+
6858+
if (Operation == AtomicRMWInst::Xchg &&
6859+
!Val->getType()->isIntegerTy() &&
6860+
!Val->getType()->isFloatingPointTy()) {
6861+
return Error(ValLoc, "atomicrmw " +
6862+
AtomicRMWInst::getOperationName(Operation) +
6863+
" operand must be an integer or floating point type");
68806864
}
68816865

68826866
unsigned Size = Val->getType()->getPrimitiveSizeInBits();

lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,8 +1034,6 @@ static AtomicRMWInst::BinOp getDecodedRMWOperation(unsigned Val) {
10341034
case bitc::RMW_MIN: return AtomicRMWInst::Min;
10351035
case bitc::RMW_UMAX: return AtomicRMWInst::UMax;
10361036
case bitc::RMW_UMIN: return AtomicRMWInst::UMin;
1037-
case bitc::RMW_FADD: return AtomicRMWInst::FAdd;
1038-
case bitc::RMW_FSUB: return AtomicRMWInst::FSub;
10391037
}
10401038
}
10411039

lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,6 @@ static unsigned getEncodedRMWOperation(AtomicRMWInst::BinOp Op) {
559559
case AtomicRMWInst::Min: return bitc::RMW_MIN;
560560
case AtomicRMWInst::UMax: return bitc::RMW_UMAX;
561561
case AtomicRMWInst::UMin: return bitc::RMW_UMIN;
562-
case AtomicRMWInst::FAdd: return bitc::RMW_FADD;
563-
case AtomicRMWInst::FSub: return bitc::RMW_FSUB;
564562
}
565563
}
566564

lib/CodeGen/AtomicExpandPass.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,6 @@ static Value *performAtomicOp(AtomicRMWInst::BinOp Op, IRBuilder<> &Builder,
549549
case AtomicRMWInst::UMin:
550550
NewVal = Builder.CreateICmpULE(Loaded, Inc);
551551
return Builder.CreateSelect(NewVal, Loaded, Inc, "new");
552-
case AtomicRMWInst::FAdd:
553-
return Builder.CreateFAdd(Loaded, Inc, "new");
554-
case AtomicRMWInst::FSub:
555-
return Builder.CreateFSub(Loaded, Inc, "new");
556552
default:
557553
llvm_unreachable("Unknown atomic op");
558554
}
@@ -1551,8 +1547,6 @@ static ArrayRef<RTLIB::Libcall> GetRMWLibcall(AtomicRMWInst::BinOp Op) {
15511547
case AtomicRMWInst::Min:
15521548
case AtomicRMWInst::UMax:
15531549
case AtomicRMWInst::UMin:
1554-
case AtomicRMWInst::FAdd:
1555-
case AtomicRMWInst::FSub:
15561550
// No atomic libcalls are available for max/min/umax/umin.
15571551
return {};
15581552
}

lib/IR/Instructions.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,10 +1407,6 @@ StringRef AtomicRMWInst::getOperationName(BinOp Op) {
14071407
return "umax";
14081408
case AtomicRMWInst::UMin:
14091409
return "umin";
1410-
case AtomicRMWInst::FAdd:
1411-
return "fadd";
1412-
case AtomicRMWInst::FSub:
1413-
return "fsub";
14141410
case AtomicRMWInst::BAD_BINOP:
14151411
return "<invalid operation>";
14161412
}

lib/IR/Verifier.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3435,11 +3435,6 @@ void Verifier::visitAtomicRMWInst(AtomicRMWInst &RMWI) {
34353435
AtomicRMWInst::getOperationName(Op) +
34363436
" operand must have integer or floating point type!",
34373437
&RMWI, ElTy);
3438-
} else if (AtomicRMWInst::isFPOperation(Op)) {
3439-
Assert(ElTy->isFloatingPointTy(), "atomicrmw " +
3440-
AtomicRMWInst::getOperationName(Op) +
3441-
" operand must have floating point type!",
3442-
&RMWI, ElTy);
34433438
} else {
34443439
Assert(ElTy->isIntegerTy(), "atomicrmw " +
34453440
AtomicRMWInst::getOperationName(Op) +

0 commit comments

Comments
 (0)