Skip to content

Commit 92ea098

Browse files
committed
Reland [llvm] Add support for llvm IR atomicrmw fminimum/fmaximum instructions (#136759)
This patch adds support for LLVM IR atomicrmw `fmaximum` and `fminimum` instructions. These mirror the `llvm.maximum.*` and `llvm.minimum.*` instructions, but are atomic and use IEEE754 2019 handling for NaNs, which is different to `fmax` and `fmin`. See: https://llvm.org/docs/LangRef.html#llvm-minimum-intrinsic for more details. Future changes will allow this LLVM IR to be lowered to specialised assembler instructions on suitable targets, such as AArch64.
1 parent 2f97695 commit 92ea098

38 files changed

+679
-73
lines changed

llvm/docs/GlobalISel/GenericOpcode.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,8 @@ operands.
922922
G_ATOMICRMW_MIN, G_ATOMICRMW_UMAX,
923923
G_ATOMICRMW_UMIN, G_ATOMICRMW_FADD,
924924
G_ATOMICRMW_FSUB, G_ATOMICRMW_FMAX,
925-
G_ATOMICRMW_FMIN, G_ATOMICRMW_UINC_WRAP,
925+
G_ATOMICRMW_FMIN, G_ATOMICRMW_FMAXIMUM,
926+
G_ATOMICRMW_FMINIMUM, G_ATOMICRMW_UINC_WRAP,
926927
G_ATOMICRMW_UDEC_WRAP, G_ATOMICRMW_USUB_COND,
927928
G_ATOMICRMW_USUB_SAT
928929

llvm/docs/LangRef.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -11598,6 +11598,8 @@ operation. The operation must be one of the following keywords:
1159811598
- fsub
1159911599
- fmax
1160011600
- fmin
11601+
- fmaximum
11602+
- fminimum
1160111603
- uinc_wrap
1160211604
- udec_wrap
1160311605
- usub_cond
@@ -11607,7 +11609,7 @@ For most of these operations, the type of '<value>' must be an integer
1160711609
type whose bit width is a power of two greater than or equal to eight
1160811610
and less than or equal to a target-specific size limit. For xchg, this
1160911611
may also be a floating point or a pointer type with the same size constraints
11610-
as integers. For fadd/fsub/fmax/fmin, this must be a floating-point
11612+
as integers. For fadd/fsub/fmax/fmin/fmaximum/fminimum, this must be a floating-point
1161111613
or fixed vector of floating-point type. The type of the '``<pointer>``'
1161211614
operand must be a pointer to that type. If the ``atomicrmw`` is marked
1161311615
as ``volatile``, then the optimizer is not allowed to modify the
@@ -11648,8 +11650,10 @@ operation argument:
1164811650
- umin: ``*ptr = *ptr < val ? *ptr : val`` (using an unsigned comparison)
1164911651
- fadd: ``*ptr = *ptr + val`` (using floating point arithmetic)
1165011652
- fsub: ``*ptr = *ptr - val`` (using floating point arithmetic)
11651-
- fmax: ``*ptr = maxnum(*ptr, val)`` (match the `llvm.maxnum.*`` intrinsic)
11652-
- fmin: ``*ptr = minnum(*ptr, val)`` (match the `llvm.minnum.*`` intrinsic)
11653+
- fmax: ``*ptr = maxnum(*ptr, val)`` (match the `llvm.maxnum.*` intrinsic)
11654+
- fmin: ``*ptr = minnum(*ptr, val)`` (match the `llvm.minnum.*` intrinsic)
11655+
- fmaximum: ``*ptr = maximum(*ptr, val)`` (match the `llvm.maximum.*` intrinsic)
11656+
- fminimum: ``*ptr = minimum(*ptr, val)`` (match the `llvm.minimum.*` intrinsic)
1165311657
- uinc_wrap: ``*ptr = (*ptr u>= val) ? 0 : (*ptr + 1)`` (increment value with wraparound to zero when incremented above input value)
1165411658
- udec_wrap: ``*ptr = ((*ptr == 0) || (*ptr u> val)) ? val : (*ptr - 1)`` (decrement with wraparound to input value when decremented below zero).
1165511659
- usub_cond: ``*ptr = (*ptr u>= val) ? *ptr - val : *ptr`` (subtract only if no unsigned overflow).

llvm/docs/ReleaseNotes.md

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Changes to LLVM infrastructure
7272
themselves (i.e., the `TargetIntrinsicInfo` class).
7373
* Fix Microsoft demangling of string literals to be stricter
7474
(#GH129970))
75+
* Added the support for ``fmaximum`` and ``fminimum`` in ``atomicrmw`` instruction. The
76+
comparison is expected to match the behavior of ``llvm.maximum.*`` and
77+
``llvm.minimum.*`` respectively.
7578

7679
Changes to building LLVM
7780
------------------------

llvm/include/llvm-c/Core.h

+6
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,12 @@ typedef enum {
393393
LLVMAtomicRMWBinOpUSubCond, /**<Subtracts the value only if no unsigned
394394
overflow */
395395
LLVMAtomicRMWBinOpUSubSat, /**<Subtracts the value, clamping to zero */
396+
LLVMAtomicRMWBinOpFMaximum, /**< Sets the value if it's greater than the
397+
original using an floating point comparison and
398+
return the old one */
399+
LLVMAtomicRMWBinOpFMinimum, /**< Sets the value if it's smaller than the
400+
original using an floating point comparison and
401+
return the old one */
396402
} LLVMAtomicRMWBinOp;
397403

398404
typedef enum {

llvm/include/llvm/AsmParser/LLToken.h

+2
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ enum Kind {
276276
kw_umin,
277277
kw_fmax,
278278
kw_fmin,
279+
kw_fmaximum,
280+
kw_fminimum,
279281
kw_uinc_wrap,
280282
kw_udec_wrap,
281283
kw_usub_cond,

llvm/include/llvm/Bitcode/LLVMBitCodes.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,9 @@ enum RMWOperations {
504504
RMW_UINC_WRAP = 15,
505505
RMW_UDEC_WRAP = 16,
506506
RMW_USUB_COND = 17,
507-
RMW_USUB_SAT = 18
507+
RMW_USUB_SAT = 18,
508+
RMW_FMAXIMUM = 19,
509+
RMW_FMINIMUM = 20,
508510
};
509511

510512
/// OverflowingBinaryOperatorOptionalFlags - Flags for serializing

llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h

+36
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,42 @@ class MachineIRBuilder {
16631663
const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val,
16641664
MachineMemOperand &MMO);
16651665

1666+
/// Build and insert `OldValRes<def> = G_ATOMICRMW_FMAXIMUM Addr, Val, MMO`.
1667+
///
1668+
/// Atomically replace the value at \p Addr with the floating point maximum of
1669+
/// \p Val and the original value. Puts the original value from \p Addr in \p
1670+
/// OldValRes.
1671+
///
1672+
/// \pre setBasicBlock or setMI must have been called.
1673+
/// \pre \p OldValRes must be a generic virtual register.
1674+
/// \pre \p Addr must be a generic virtual register with pointer type.
1675+
/// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1676+
/// same type.
1677+
///
1678+
/// \return a MachineInstrBuilder for the newly created instruction.
1679+
MachineInstrBuilder buildAtomicRMWFMaximum(const DstOp &OldValRes,
1680+
const SrcOp &Addr,
1681+
const SrcOp &Val,
1682+
MachineMemOperand &MMO);
1683+
1684+
/// Build and insert `OldValRes<def> = G_ATOMICRMW_FMINIMUM Addr, Val, MMO`.
1685+
///
1686+
/// Atomically replace the value at \p Addr with the floating point minimum of
1687+
/// \p Val and the original value. Puts the original value from \p Addr in \p
1688+
/// OldValRes.
1689+
///
1690+
/// \pre setBasicBlock or setMI must have been called.
1691+
/// \pre \p OldValRes must be a generic virtual register.
1692+
/// \pre \p Addr must be a generic virtual register with pointer type.
1693+
/// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1694+
/// same type.
1695+
///
1696+
/// \return a MachineInstrBuilder for the newly created instruction.
1697+
MachineInstrBuilder buildAtomicRMWFMinimum(const DstOp &OldValRes,
1698+
const SrcOp &Addr,
1699+
const SrcOp &Val,
1700+
MachineMemOperand &MMO);
1701+
16661702
/// Build and insert `OldValRes<def> = G_ATOMICRMW_USUB_COND Addr, Val, MMO`.
16671703
///
16681704
/// Atomically replace the value at \p Addr with the original value minus \p

llvm/include/llvm/CodeGen/ISDOpcodes.h

+2
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,8 @@ enum NodeType {
13761376
ATOMIC_LOAD_FSUB,
13771377
ATOMIC_LOAD_FMAX,
13781378
ATOMIC_LOAD_FMIN,
1379+
ATOMIC_LOAD_FMAXIMUM,
1380+
ATOMIC_LOAD_FMINIMUM,
13791381
ATOMIC_LOAD_UINC_WRAP,
13801382
ATOMIC_LOAD_UDEC_WRAP,
13811383
ATOMIC_LOAD_USUB_COND,

llvm/include/llvm/CodeGen/SelectionDAGNodes.h

+4
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,8 @@ class MemSDNode : public SDNode {
15171517
case ISD::ATOMIC_LOAD_FSUB:
15181518
case ISD::ATOMIC_LOAD_FMAX:
15191519
case ISD::ATOMIC_LOAD_FMIN:
1520+
case ISD::ATOMIC_LOAD_FMAXIMUM:
1521+
case ISD::ATOMIC_LOAD_FMINIMUM:
15201522
case ISD::ATOMIC_LOAD_UINC_WRAP:
15211523
case ISD::ATOMIC_LOAD_UDEC_WRAP:
15221524
case ISD::ATOMIC_LOAD_USUB_COND:
@@ -1603,6 +1605,8 @@ class AtomicSDNode : public MemSDNode {
16031605
N->getOpcode() == ISD::ATOMIC_LOAD_FSUB ||
16041606
N->getOpcode() == ISD::ATOMIC_LOAD_FMAX ||
16051607
N->getOpcode() == ISD::ATOMIC_LOAD_FMIN ||
1608+
N->getOpcode() == ISD::ATOMIC_LOAD_FMAXIMUM ||
1609+
N->getOpcode() == ISD::ATOMIC_LOAD_FMINIMUM ||
16061610
N->getOpcode() == ISD::ATOMIC_LOAD_UINC_WRAP ||
16071611
N->getOpcode() == ISD::ATOMIC_LOAD_UDEC_WRAP ||
16081612
N->getOpcode() == ISD::ATOMIC_LOAD_USUB_COND ||

llvm/include/llvm/IR/Instructions.h

+10
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,14 @@ class AtomicRMWInst : public Instruction {
751751
/// \p minnum matches the behavior of \p llvm.minnum.*.
752752
FMin,
753753

754+
/// *p = maximum(old, v)
755+
/// \p maximum matches the behavior of \p llvm.maximum.*.
756+
FMaximum,
757+
758+
/// *p = minimum(old, v)
759+
/// \p minimum matches the behavior of \p llvm.minimum.*.
760+
FMinimum,
761+
754762
/// Increment one up to a maximum value.
755763
/// *p = (old u>= v) ? 0 : (old + 1)
756764
UIncWrap,
@@ -812,6 +820,8 @@ class AtomicRMWInst : public Instruction {
812820
case AtomicRMWInst::FSub:
813821
case AtomicRMWInst::FMax:
814822
case AtomicRMWInst::FMin:
823+
case AtomicRMWInst::FMaximum:
824+
case AtomicRMWInst::FMinimum:
815825
return true;
816826
default:
817827
return false;

llvm/include/llvm/Support/TargetOpcodes.def

+2
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ HANDLE_TARGET_OPCODE(G_ATOMICRMW_FADD)
426426
HANDLE_TARGET_OPCODE(G_ATOMICRMW_FSUB)
427427
HANDLE_TARGET_OPCODE(G_ATOMICRMW_FMAX)
428428
HANDLE_TARGET_OPCODE(G_ATOMICRMW_FMIN)
429+
HANDLE_TARGET_OPCODE(G_ATOMICRMW_FMAXIMUM)
430+
HANDLE_TARGET_OPCODE(G_ATOMICRMW_FMINIMUM)
429431
HANDLE_TARGET_OPCODE(G_ATOMICRMW_UINC_WRAP)
430432
HANDLE_TARGET_OPCODE(G_ATOMICRMW_UDEC_WRAP)
431433
HANDLE_TARGET_OPCODE(G_ATOMICRMW_USUB_COND)

llvm/include/llvm/Target/GenericOpcodes.td

+2
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,8 @@ def G_ATOMICRMW_FADD : G_ATOMICRMW_OP;
13511351
def G_ATOMICRMW_FSUB : G_ATOMICRMW_OP;
13521352
def G_ATOMICRMW_FMAX : G_ATOMICRMW_OP;
13531353
def G_ATOMICRMW_FMIN : G_ATOMICRMW_OP;
1354+
def G_ATOMICRMW_FMAXIMUM : G_ATOMICRMW_OP;
1355+
def G_ATOMICRMW_FMINIMUM : G_ATOMICRMW_OP;
13541356
def G_ATOMICRMW_UINC_WRAP : G_ATOMICRMW_OP;
13551357
def G_ATOMICRMW_UDEC_WRAP : G_ATOMICRMW_OP;
13561358
def G_ATOMICRMW_USUB_COND : G_ATOMICRMW_OP;

llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td

+2
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ def : GINodeEquiv<G_ATOMICRMW_FADD, atomic_load_fadd>;
266266
def : GINodeEquiv<G_ATOMICRMW_FSUB, atomic_load_fsub>;
267267
def : GINodeEquiv<G_ATOMICRMW_FMAX, atomic_load_fmax>;
268268
def : GINodeEquiv<G_ATOMICRMW_FMIN, atomic_load_fmin>;
269+
def : GINodeEquiv<G_ATOMICRMW_FMAXIMUM, atomic_load_fmaximum>;
270+
def : GINodeEquiv<G_ATOMICRMW_FMINIMUM, atomic_load_fminimum>;
269271
def : GINodeEquiv<G_ATOMICRMW_UINC_WRAP, atomic_load_uinc_wrap>;
270272
def : GINodeEquiv<G_ATOMICRMW_UDEC_WRAP, atomic_load_udec_wrap>;
271273
def : GINodeEquiv<G_ATOMICRMW_USUB_COND, atomic_load_usub_cond>;

llvm/include/llvm/Target/TargetSelectionDAG.td

+4
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,10 @@ def atomic_load_fmax : SDNode<"ISD::ATOMIC_LOAD_FMAX", SDTFPAtomic2,
781781
[SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
782782
def atomic_load_fmin : SDNode<"ISD::ATOMIC_LOAD_FMIN", SDTFPAtomic2,
783783
[SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
784+
def atomic_load_fmaximum : SDNode<"ISD::ATOMIC_LOAD_FMAXIMUM", SDTFPAtomic2,
785+
[SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
786+
def atomic_load_fminimum : SDNode<"ISD::ATOMIC_LOAD_FMINIMUM", SDTFPAtomic2,
787+
[SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
784788
def atomic_load_uinc_wrap : SDNode<"ISD::ATOMIC_LOAD_UINC_WRAP", SDTAtomic2,
785789
[SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
786790
def atomic_load_udec_wrap : SDNode<"ISD::ATOMIC_LOAD_UDEC_WRAP", SDTAtomic2,

llvm/lib/AsmParser/LLLexer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,8 @@ lltok::Kind LLLexer::LexIdentifier() {
749749

750750
KEYWORD(xchg); KEYWORD(nand); KEYWORD(max); KEYWORD(min); KEYWORD(umax);
751751
KEYWORD(umin); KEYWORD(fmax); KEYWORD(fmin);
752+
KEYWORD(fmaximum);
753+
KEYWORD(fminimum);
752754
KEYWORD(uinc_wrap);
753755
KEYWORD(udec_wrap);
754756
KEYWORD(usub_cond);

llvm/lib/AsmParser/LLParser.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -8626,6 +8626,14 @@ int LLParser::parseAtomicRMW(Instruction *&Inst, PerFunctionState &PFS) {
86268626
Operation = AtomicRMWInst::FMin;
86278627
IsFP = true;
86288628
break;
8629+
case lltok::kw_fmaximum:
8630+
Operation = AtomicRMWInst::FMaximum;
8631+
IsFP = true;
8632+
break;
8633+
case lltok::kw_fminimum:
8634+
Operation = AtomicRMWInst::FMinimum;
8635+
IsFP = true;
8636+
break;
86298637
}
86308638
Lex.Lex(); // Eat the operation.
86318639

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,10 @@ static AtomicRMWInst::BinOp getDecodedRMWOperation(unsigned Val) {
13561356
case bitc::RMW_FSUB: return AtomicRMWInst::FSub;
13571357
case bitc::RMW_FMAX: return AtomicRMWInst::FMax;
13581358
case bitc::RMW_FMIN: return AtomicRMWInst::FMin;
1359+
case bitc::RMW_FMAXIMUM:
1360+
return AtomicRMWInst::FMaximum;
1361+
case bitc::RMW_FMINIMUM:
1362+
return AtomicRMWInst::FMinimum;
13591363
case bitc::RMW_UINC_WRAP:
13601364
return AtomicRMWInst::UIncWrap;
13611365
case bitc::RMW_UDEC_WRAP:

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,10 @@ static unsigned getEncodedRMWOperation(AtomicRMWInst::BinOp Op) {
678678
case AtomicRMWInst::FSub: return bitc::RMW_FSUB;
679679
case AtomicRMWInst::FMax: return bitc::RMW_FMAX;
680680
case AtomicRMWInst::FMin: return bitc::RMW_FMIN;
681+
case AtomicRMWInst::FMaximum:
682+
return bitc::RMW_FMAXIMUM;
683+
case AtomicRMWInst::FMinimum:
684+
return bitc::RMW_FMINIMUM;
681685
case AtomicRMWInst::UIncWrap:
682686
return bitc::RMW_UINC_WRAP;
683687
case AtomicRMWInst::UDecWrap:

llvm/lib/CodeGen/AtomicExpandPass.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,8 @@ static Value *performMaskedAtomicOp(AtomicRMWInst::BinOp Op,
931931
case AtomicRMWInst::FSub:
932932
case AtomicRMWInst::FMin:
933933
case AtomicRMWInst::FMax:
934+
case AtomicRMWInst::FMaximum:
935+
case AtomicRMWInst::FMinimum:
934936
case AtomicRMWInst::UIncWrap:
935937
case AtomicRMWInst::UDecWrap:
936938
case AtomicRMWInst::USubCond:
@@ -1819,6 +1821,8 @@ static ArrayRef<RTLIB::Libcall> GetRMWLibcall(AtomicRMWInst::BinOp Op) {
18191821
case AtomicRMWInst::UMin:
18201822
case AtomicRMWInst::FMax:
18211823
case AtomicRMWInst::FMin:
1824+
case AtomicRMWInst::FMaximum:
1825+
case AtomicRMWInst::FMinimum:
18221826
case AtomicRMWInst::FAdd:
18231827
case AtomicRMWInst::FSub:
18241828
case AtomicRMWInst::UIncWrap:

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -3435,6 +3435,12 @@ bool IRTranslator::translateAtomicRMW(const User &U,
34353435
case AtomicRMWInst::FMin:
34363436
Opcode = TargetOpcode::G_ATOMICRMW_FMIN;
34373437
break;
3438+
case AtomicRMWInst::FMaximum:
3439+
Opcode = TargetOpcode::G_ATOMICRMW_FMAXIMUM;
3440+
break;
3441+
case AtomicRMWInst::FMinimum:
3442+
Opcode = TargetOpcode::G_ATOMICRMW_FMINIMUM;
3443+
break;
34383444
case AtomicRMWInst::UIncWrap:
34393445
Opcode = TargetOpcode::G_ATOMICRMW_UINC_WRAP;
34403446
break;

llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,22 @@ MachineIRBuilder::buildAtomicRMWFMin(const DstOp &OldValRes, const SrcOp &Addr,
11571157
MMO);
11581158
}
11591159

1160+
MachineInstrBuilder
1161+
MachineIRBuilder::buildAtomicRMWFMaximum(const DstOp &OldValRes,
1162+
const SrcOp &Addr, const SrcOp &Val,
1163+
MachineMemOperand &MMO) {
1164+
return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FMAXIMUM, OldValRes, Addr,
1165+
Val, MMO);
1166+
}
1167+
1168+
MachineInstrBuilder
1169+
MachineIRBuilder::buildAtomicRMWFMinimum(const DstOp &OldValRes,
1170+
const SrcOp &Addr, const SrcOp &Val,
1171+
MachineMemOperand &MMO) {
1172+
return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FMINIMUM, OldValRes, Addr,
1173+
Val, MMO);
1174+
}
1175+
11601176
MachineInstrBuilder
11611177
MachineIRBuilder::buildFence(unsigned Ordering, unsigned Scope) {
11621178
return buildInstr(TargetOpcode::G_FENCE)

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -9101,6 +9101,8 @@ SDValue SelectionDAG::getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT,
91019101
Opcode == ISD::ATOMIC_LOAD_UMAX || Opcode == ISD::ATOMIC_LOAD_FADD ||
91029102
Opcode == ISD::ATOMIC_LOAD_FSUB || Opcode == ISD::ATOMIC_LOAD_FMAX ||
91039103
Opcode == ISD::ATOMIC_LOAD_FMIN ||
9104+
Opcode == ISD::ATOMIC_LOAD_FMINIMUM ||
9105+
Opcode == ISD::ATOMIC_LOAD_FMAXIMUM ||
91049106
Opcode == ISD::ATOMIC_LOAD_UINC_WRAP ||
91059107
Opcode == ISD::ATOMIC_LOAD_UDEC_WRAP ||
91069108
Opcode == ISD::ATOMIC_LOAD_USUB_COND ||

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -5081,6 +5081,12 @@ void SelectionDAGBuilder::visitAtomicRMW(const AtomicRMWInst &I) {
50815081
case AtomicRMWInst::FSub: NT = ISD::ATOMIC_LOAD_FSUB; break;
50825082
case AtomicRMWInst::FMax: NT = ISD::ATOMIC_LOAD_FMAX; break;
50835083
case AtomicRMWInst::FMin: NT = ISD::ATOMIC_LOAD_FMIN; break;
5084+
case AtomicRMWInst::FMaximum:
5085+
NT = ISD::ATOMIC_LOAD_FMAXIMUM;
5086+
break;
5087+
case AtomicRMWInst::FMinimum:
5088+
NT = ISD::ATOMIC_LOAD_FMINIMUM;
5089+
break;
50845090
case AtomicRMWInst::UIncWrap:
50855091
NT = ISD::ATOMIC_LOAD_UINC_WRAP;
50865092
break;

llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
103103
case ISD::ATOMIC_LOAD_FSUB: return "AtomicLoadFSub";
104104
case ISD::ATOMIC_LOAD_FMIN: return "AtomicLoadFMin";
105105
case ISD::ATOMIC_LOAD_FMAX: return "AtomicLoadFMax";
106+
case ISD::ATOMIC_LOAD_FMINIMUM: return "AtomicLoadFMinimum";
107+
case ISD::ATOMIC_LOAD_FMAXIMUM: return "AtomicLoadFMaximum";
106108
case ISD::ATOMIC_LOAD_UINC_WRAP:
107109
return "AtomicLoadUIncWrap";
108110
case ISD::ATOMIC_LOAD_UDEC_WRAP:

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -8768,6 +8768,8 @@ Value *OpenMPIRBuilder::emitRMWOpAsInstruction(Value *Src1, Value *Src2,
87688768
case AtomicRMWInst::UMin:
87698769
case AtomicRMWInst::FMax:
87708770
case AtomicRMWInst::FMin:
8771+
case AtomicRMWInst::FMaximum:
8772+
case AtomicRMWInst::FMinimum:
87718773
case AtomicRMWInst::UIncWrap:
87728774
case AtomicRMWInst::UDecWrap:
87738775
case AtomicRMWInst::USubCond:

llvm/lib/IR/Core.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -3955,6 +3955,10 @@ static AtomicRMWInst::BinOp mapFromLLVMRMWBinOp(LLVMAtomicRMWBinOp BinOp) {
39553955
case LLVMAtomicRMWBinOpFSub: return AtomicRMWInst::FSub;
39563956
case LLVMAtomicRMWBinOpFMax: return AtomicRMWInst::FMax;
39573957
case LLVMAtomicRMWBinOpFMin: return AtomicRMWInst::FMin;
3958+
case LLVMAtomicRMWBinOpFMaximum:
3959+
return AtomicRMWInst::FMaximum;
3960+
case LLVMAtomicRMWBinOpFMinimum:
3961+
return AtomicRMWInst::FMinimum;
39583962
case LLVMAtomicRMWBinOpUIncWrap:
39593963
return AtomicRMWInst::UIncWrap;
39603964
case LLVMAtomicRMWBinOpUDecWrap:
@@ -3985,6 +3989,10 @@ static LLVMAtomicRMWBinOp mapToLLVMRMWBinOp(AtomicRMWInst::BinOp BinOp) {
39853989
case AtomicRMWInst::FSub: return LLVMAtomicRMWBinOpFSub;
39863990
case AtomicRMWInst::FMax: return LLVMAtomicRMWBinOpFMax;
39873991
case AtomicRMWInst::FMin: return LLVMAtomicRMWBinOpFMin;
3992+
case AtomicRMWInst::FMaximum:
3993+
return LLVMAtomicRMWBinOpFMaximum;
3994+
case AtomicRMWInst::FMinimum:
3995+
return LLVMAtomicRMWBinOpFMinimum;
39883996
case AtomicRMWInst::UIncWrap:
39893997
return LLVMAtomicRMWBinOpUIncWrap;
39903998
case AtomicRMWInst::UDecWrap:

llvm/lib/IR/Instructions.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,10 @@ StringRef AtomicRMWInst::getOperationName(BinOp Op) {
14811481
return "fmax";
14821482
case AtomicRMWInst::FMin:
14831483
return "fmin";
1484+
case AtomicRMWInst::FMaximum:
1485+
return "fmaximum";
1486+
case AtomicRMWInst::FMinimum:
1487+
return "fminimum";
14841488
case AtomicRMWInst::UIncWrap:
14851489
return "uinc_wrap";
14861490
case AtomicRMWInst::UDecWrap:

0 commit comments

Comments
 (0)