Skip to content

Commit b1542af

Browse files
authored
[RISCV] Rename merge operand -> passthru. NFC (llvm#100330)
We sometimes call the first tied dest operand in vector pseudos the merge operand, and other times the passthru. Passthru seems to be more common, and it's what the C intrinsics call it[^1], so this renames all usages of merge to passthru to be consistent. It also helps prevent confusion with vmerge.vvm in some of the peephole optimisations. [^1]: https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/main/doc/rvv-intrinsic-spec.adoc#the-passthrough-vd-argument-in-the-intrinsics
1 parent 96b1ae8 commit b1542af

14 files changed

+504
-503
lines changed

llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ static bool lowerRISCVVMachineInstrToMCInst(const MachineInstr *MI,
976976
if (hasVLOutput && OpNo == 1)
977977
continue;
978978

979-
// Skip merge op. It should be the first operand after the defs.
979+
// Skip passthru op. It should be the first operand after the defs.
980980
if (OpNo == MI->getNumExplicitDefs() && MO.isReg() && MO.isTied()) {
981981
assert(MCID.getOperandConstraint(OpNo, MCOI::TIED_TO) == 0 &&
982982
"Expected tied to first def.");

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3633,7 +3633,7 @@ bool RISCVDAGToDAGISel::doPeepholeMaskedRVV(MachineSDNode *N) {
36333633
#endif
36343634

36353635
SmallVector<SDValue, 8> Ops;
3636-
// Skip the merge operand at index 0 if !UseTUPseudo.
3636+
// Skip the passthru operand at index 0 if !UseTUPseudo.
36373637
for (unsigned I = !UseTUPseudo, E = N->getNumOperands(); I != E; I++) {
36383638
// Skip the mask, and the Glue.
36393639
SDValue Op = N->getOperand(I);
@@ -3696,9 +3696,9 @@ static unsigned GetVMSetForLMul(RISCVII::VLMUL LMUL) {
36963696
// ->
36973697
// %x = PseudoVADD_VV_MASK %false, ..., %mask
36983698
//
3699-
// We can only fold if vmerge's merge operand, vmerge's false operand and
3700-
// %true's merge operand (if it has one) are the same. This is because we have
3701-
// to consolidate them into one merge operand in the result.
3699+
// We can only fold if vmerge's passthru operand, vmerge's false operand and
3700+
// %true's passthru operand (if it has one) are the same. This is because we
3701+
// have to consolidate them into one passthru operand in the result.
37023702
//
37033703
// If %true is masked, then we can use its mask instead of vmerge's if vmerge's
37043704
// mask is all ones.
@@ -3709,20 +3709,20 @@ static unsigned GetVMSetForLMul(RISCVII::VLMUL LMUL) {
37093709
// The resulting VL is the minimum of the two VLs.
37103710
//
37113711
// The resulting policy is the effective policy the vmerge would have had,
3712-
// i.e. whether or not it's merge operand was implicit-def.
3712+
// i.e. whether or not it's passthru operand was implicit-def.
37133713
bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
3714-
SDValue Merge, False, True, VL, Mask, Glue;
3714+
SDValue Passthru, False, True, VL, Mask, Glue;
37153715
// A vmv.v.v is equivalent to a vmerge with an all-ones mask.
37163716
if (IsVMv(N)) {
3717-
Merge = N->getOperand(0);
3717+
Passthru = N->getOperand(0);
37183718
False = N->getOperand(0);
37193719
True = N->getOperand(1);
37203720
VL = N->getOperand(2);
37213721
// A vmv.v.v won't have a Mask or Glue, instead we'll construct an all-ones
37223722
// mask later below.
37233723
} else {
37243724
assert(IsVMerge(N));
3725-
Merge = N->getOperand(0);
3725+
Passthru = N->getOperand(0);
37263726
False = N->getOperand(1);
37273727
True = N->getOperand(2);
37283728
Mask = N->getOperand(3);
@@ -3733,9 +3733,9 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
37333733
assert(!Mask || cast<RegisterSDNode>(Mask)->getReg() == RISCV::V0);
37343734
assert(!Glue || Glue.getValueType() == MVT::Glue);
37353735

3736-
// We require that either merge and false are the same, or that merge
3736+
// We require that either passthru and false are the same, or that passthru
37373737
// is undefined.
3738-
if (Merge != False && !isImplicitDef(Merge))
3738+
if (Passthru != False && !isImplicitDef(Passthru))
37393739
return false;
37403740

37413741
assert(True.getResNo() == 0 &&
@@ -3765,19 +3765,19 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
37653765
if (!Info)
37663766
return false;
37673767

3768-
// If True has a merge operand then it needs to be the same as vmerge's False,
3769-
// since False will be used for the result's merge operand.
3768+
// If True has a passthru operand then it needs to be the same as vmerge's
3769+
// False, since False will be used for the result's passthru operand.
37703770
if (HasTiedDest && !isImplicitDef(True->getOperand(0))) {
3771-
SDValue MergeOpTrue = True->getOperand(0);
3772-
if (False != MergeOpTrue)
3771+
SDValue PassthruOpTrue = True->getOperand(0);
3772+
if (False != PassthruOpTrue)
37733773
return false;
37743774
}
37753775

37763776
// If True is masked then the vmerge must have either the same mask or an all
37773777
// 1s mask, since we're going to keep the mask from True.
37783778
if (IsMasked && Mask) {
37793779
// FIXME: Support mask agnostic True instruction which would have an
3780-
// undef merge operand.
3780+
// undef passthru operand.
37813781
SDValue TrueMask =
37823782
getMaskSetter(True->getOperand(Info->MaskOpIdx),
37833783
True->getOperand(True->getNumOperands() - 1));
@@ -3835,8 +3835,8 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
38353835
return CLHS->getZExtValue() <= CRHS->getZExtValue() ? LHS : RHS;
38363836
};
38373837

3838-
// Because N and True must have the same merge operand (or True's operand is
3839-
// implicit_def), the "effective" body is the minimum of their VLs.
3838+
// Because N and True must have the same passthru operand (or True's operand
3839+
// is implicit_def), the "effective" body is the minimum of their VLs.
38403840
SDValue OrigVL = VL;
38413841
VL = GetMinVL(TrueVL, VL);
38423842
if (!VL)
@@ -3895,15 +3895,15 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
38953895
"Expected instructions with mask have a tied dest.");
38963896
#endif
38973897

3898-
// Use a tumu policy, relaxing it to tail agnostic provided that the merge
3898+
// Use a tumu policy, relaxing it to tail agnostic provided that the passthru
38993899
// operand is undefined.
39003900
//
39013901
// However, if the VL became smaller than what the vmerge had originally, then
39023902
// elements past VL that were previously in the vmerge's body will have moved
39033903
// to the tail. In that case we always need to use tail undisturbed to
39043904
// preserve them.
39053905
bool MergeVLShrunk = VL != OrigVL;
3906-
uint64_t Policy = (isImplicitDef(Merge) && !MergeVLShrunk)
3906+
uint64_t Policy = (isImplicitDef(Passthru) && !MergeVLShrunk)
39073907
? RISCVII::TAIL_AGNOSTIC
39083908
: /*TUMU*/ 0;
39093909
SDValue PolicyOp =

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,25 +3294,25 @@ static SDValue lowerVectorXRINT(SDValue Op, SelectionDAG &DAG,
32943294

32953295
static SDValue
32963296
getVSlidedown(SelectionDAG &DAG, const RISCVSubtarget &Subtarget,
3297-
const SDLoc &DL, EVT VT, SDValue Merge, SDValue Op,
3297+
const SDLoc &DL, EVT VT, SDValue Passthru, SDValue Op,
32983298
SDValue Offset, SDValue Mask, SDValue VL,
32993299
unsigned Policy = RISCVII::TAIL_UNDISTURBED_MASK_UNDISTURBED) {
3300-
if (Merge.isUndef())
3300+
if (Passthru.isUndef())
33013301
Policy = RISCVII::TAIL_AGNOSTIC | RISCVII::MASK_AGNOSTIC;
33023302
SDValue PolicyOp = DAG.getTargetConstant(Policy, DL, Subtarget.getXLenVT());
3303-
SDValue Ops[] = {Merge, Op, Offset, Mask, VL, PolicyOp};
3303+
SDValue Ops[] = {Passthru, Op, Offset, Mask, VL, PolicyOp};
33043304
return DAG.getNode(RISCVISD::VSLIDEDOWN_VL, DL, VT, Ops);
33053305
}
33063306

33073307
static SDValue
33083308
getVSlideup(SelectionDAG &DAG, const RISCVSubtarget &Subtarget, const SDLoc &DL,
3309-
EVT VT, SDValue Merge, SDValue Op, SDValue Offset, SDValue Mask,
3309+
EVT VT, SDValue Passthru, SDValue Op, SDValue Offset, SDValue Mask,
33103310
SDValue VL,
33113311
unsigned Policy = RISCVII::TAIL_UNDISTURBED_MASK_UNDISTURBED) {
3312-
if (Merge.isUndef())
3312+
if (Passthru.isUndef())
33133313
Policy = RISCVII::TAIL_AGNOSTIC | RISCVII::MASK_AGNOSTIC;
33143314
SDValue PolicyOp = DAG.getTargetConstant(Policy, DL, Subtarget.getXLenVT());
3315-
SDValue Ops[] = {Merge, Op, Offset, Mask, VL, PolicyOp};
3315+
SDValue Ops[] = {Passthru, Op, Offset, Mask, VL, PolicyOp};
33163316
return DAG.getNode(RISCVISD::VSLIDEUP_VL, DL, VT, Ops);
33173317
}
33183318

@@ -6086,8 +6086,8 @@ static unsigned getRISCVVLOp(SDValue Op) {
60866086
#undef VP_CASE
60876087
}
60886088

6089-
/// Return true if a RISC-V target specified op has a merge operand.
6090-
static bool hasMergeOp(unsigned Opcode) {
6089+
/// Return true if a RISC-V target specified op has a passthru operand.
6090+
static bool hasPassthruOp(unsigned Opcode) {
60916091
assert(Opcode > RISCVISD::FIRST_NUMBER &&
60926092
Opcode <= RISCVISD::LAST_RISCV_STRICTFP_OPCODE &&
60936093
"not a RISC-V target specific op");
@@ -10953,7 +10953,7 @@ SDValue RISCVTargetLowering::lowerVectorStrictFSetcc(SDValue Op,
1095310953
True, VL});
1095410954
Mask =
1095510955
DAG.getNode(RISCVISD::VMAND_VL, DL, MaskVT, OrderMask1, OrderMask2, VL);
10956-
// Use Mask as the merge operand to let the result be 0 if either of the
10956+
// Use Mask as the passthru operand to let the result be 0 if either of the
1095710957
// inputs is unordered.
1095810958
Res = DAG.getNode(RISCVISD::STRICT_FSETCCS_VL, DL,
1095910959
DAG.getVTList(MaskVT, MVT::Other),
@@ -11058,7 +11058,7 @@ SDValue RISCVTargetLowering::lowerFixedLengthVectorSelectToRVV(
1105811058
SDValue RISCVTargetLowering::lowerToScalableOp(SDValue Op,
1105911059
SelectionDAG &DAG) const {
1106011060
unsigned NewOpc = getRISCVVLOp(Op);
11061-
bool HasMergeOp = hasMergeOp(NewOpc);
11061+
bool HasPassthruOp = hasPassthruOp(NewOpc);
1106211062
bool HasMask = hasMaskOp(NewOpc);
1106311063

1106411064
MVT VT = Op.getSimpleValueType();
@@ -11083,7 +11083,7 @@ SDValue RISCVTargetLowering::lowerToScalableOp(SDValue Op,
1108311083

1108411084
SDLoc DL(Op);
1108511085
auto [Mask, VL] = getDefaultVLOps(VT, ContainerVT, DL, DAG, Subtarget);
11086-
if (HasMergeOp)
11086+
if (HasPassthruOp)
1108711087
Ops.push_back(DAG.getUNDEF(ContainerVT));
1108811088
if (HasMask)
1108911089
Ops.push_back(Mask);
@@ -11111,7 +11111,7 @@ SDValue RISCVTargetLowering::lowerToScalableOp(SDValue Op,
1111111111
// types.
1111211112
SDValue RISCVTargetLowering::lowerVPOp(SDValue Op, SelectionDAG &DAG) const {
1111311113
unsigned RISCVISDOpc = getRISCVVLOp(Op);
11114-
bool HasMergeOp = hasMergeOp(RISCVISDOpc);
11114+
bool HasPassthruOp = hasPassthruOp(RISCVISDOpc);
1111511115

1111611116
SDLoc DL(Op);
1111711117
MVT VT = Op.getSimpleValueType();
@@ -11124,9 +11124,9 @@ SDValue RISCVTargetLowering::lowerVPOp(SDValue Op, SelectionDAG &DAG) const {
1112411124
for (const auto &OpIdx : enumerate(Op->ops())) {
1112511125
SDValue V = OpIdx.value();
1112611126
assert(!isa<VTSDNode>(V) && "Unexpected VTSDNode node!");
11127-
// Add dummy merge value before the mask. Or if there isn't a mask, before
11128-
// EVL.
11129-
if (HasMergeOp) {
11127+
// Add dummy passthru value before the mask. Or if there isn't a mask,
11128+
// before EVL.
11129+
if (HasPassthruOp) {
1113011130
auto MaskIdx = ISD::getVPMaskIdx(Op.getOpcode());
1113111131
if (MaskIdx) {
1113211132
if (*MaskIdx == OpIdx.index())
@@ -14658,25 +14658,25 @@ struct CombineResult {
1465814658
/// The actual replacement is *not* done in that method.
1465914659
SDValue materialize(SelectionDAG &DAG,
1466014660
const RISCVSubtarget &Subtarget) const {
14661-
SDValue Mask, VL, Merge;
14661+
SDValue Mask, VL, Passthru;
1466214662
std::tie(Mask, VL) =
1466314663
NodeExtensionHelper::getMaskAndVL(Root, DAG, Subtarget);
1466414664
switch (Root->getOpcode()) {
1466514665
default:
14666-
Merge = Root->getOperand(2);
14666+
Passthru = Root->getOperand(2);
1466714667
break;
1466814668
case ISD::ADD:
1466914669
case ISD::SUB:
1467014670
case ISD::MUL:
1467114671
case ISD::OR:
1467214672
case ISD::SHL:
14673-
Merge = DAG.getUNDEF(Root->getValueType(0));
14673+
Passthru = DAG.getUNDEF(Root->getValueType(0));
1467414674
break;
1467514675
}
1467614676
return DAG.getNode(TargetOpcode, SDLoc(Root), Root->getValueType(0),
1467714677
LHS.getOrCreateExtendedOp(Root, DAG, Subtarget, LHSExt),
1467814678
RHS.getOrCreateExtendedOp(Root, DAG, Subtarget, RHSExt),
14679-
Merge, Mask, VL);
14679+
Passthru, Mask, VL);
1468014680
}
1468114681
};
1468214682

@@ -16159,8 +16159,8 @@ static SDValue combineToVWMACC(SDNode *N, SelectionDAG &DAG,
1615916159
SDValue MulOp = N->getOperand(1);
1616016160

1616116161
if (N->getOpcode() == RISCVISD::ADD_VL) {
16162-
SDValue AddMergeOp = N->getOperand(2);
16163-
if (!AddMergeOp.isUndef())
16162+
SDValue AddPassthruOp = N->getOperand(2);
16163+
if (!AddPassthruOp.isUndef())
1616416164
return SDValue();
1616516165
}
1616616166

@@ -16181,9 +16181,9 @@ static SDValue combineToVWMACC(SDNode *N, SelectionDAG &DAG,
1618116181
if (!IsVWMulOpc(MulOp.getOpcode()))
1618216182
return SDValue();
1618316183

16184-
SDValue MulMergeOp = MulOp.getOperand(2);
16184+
SDValue MulPassthruOp = MulOp.getOperand(2);
1618516185

16186-
if (!MulMergeOp.isUndef())
16186+
if (!MulPassthruOp.isUndef())
1618716187
return SDValue();
1618816188

1618916189
auto [AddMask, AddVL] = [](SDNode *N, SelectionDAG &DAG,

llvm/lib/Target/RISCV/RISCVISelLowering.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ enum NodeType : unsigned {
238238
VECREDUCE_FMIN_VL,
239239
VECREDUCE_FMAX_VL,
240240

241-
// Vector binary ops with a merge as a third operand, a mask as a fourth
241+
// Vector binary ops with a passthru as a third operand, a mask as a fourth
242242
// operand, and VL as a fifth operand.
243243
ADD_VL,
244244
AND_VL,
@@ -294,7 +294,7 @@ enum NodeType : unsigned {
294294
FABS_VL,
295295
FSQRT_VL,
296296
FCLASS_VL,
297-
FCOPYSIGN_VL, // Has a merge operand
297+
FCOPYSIGN_VL, // Has a passthru operand
298298
VFCVT_RTZ_X_F_VL,
299299
VFCVT_RTZ_XU_F_VL,
300300
VFCVT_X_F_VL,
@@ -322,7 +322,7 @@ enum NodeType : unsigned {
322322
VFWMSUB_VL,
323323
VFWNMSUB_VL,
324324

325-
// Widening instructions with a merge value a third operand, a mask as a
325+
// Widening instructions with a passthru value a third operand, a mask as a
326326
// fourth operand, and VL as a fifth operand.
327327
VWMUL_VL,
328328
VWMULU_VL,

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static bool isMaskRegOp(const MachineInstr &MI) {
182182
/// Note that this is different from "agnostic" as defined by the vector
183183
/// specification. Agnostic requires each lane to either be undisturbed, or
184184
/// take the value -1; no other value is allowed.
185-
static bool hasUndefinedMergeOp(const MachineInstr &MI) {
185+
static bool hasUndefinedPassthru(const MachineInstr &MI) {
186186

187187
unsigned UseOpIdx;
188188
if (!MI.isRegTiedToUseOperand(0, &UseOpIdx))
@@ -443,13 +443,13 @@ DemandedFields getDemanded(const MachineInstr &MI, const RISCVSubtarget *ST) {
443443
Res.LMUL = DemandedFields::LMULNone;
444444
Res.SEWLMULRatio = false;
445445
Res.VLAny = false;
446-
// For vmv.s.x and vfmv.s.f, if the merge operand is *undefined*, we don't
446+
// For vmv.s.x and vfmv.s.f, if the passthru is *undefined*, we don't
447447
// need to preserve any other bits and are thus compatible with any larger,
448448
// etype and can disregard policy bits. Warning: It's tempting to try doing
449449
// this for any tail agnostic operation, but we can't as TA requires
450450
// tail lanes to either be the original value or -1. We are writing
451451
// unknown bits to the lanes here.
452-
if (hasUndefinedMergeOp(MI)) {
452+
if (hasUndefinedPassthru(MI)) {
453453
if (isFloatScalarMoveOrScalarSplatInstr(MI) && !ST->hasVInstructionsF64())
454454
Res.SEW = DemandedFields::SEWGreaterThanOrEqualAndLessThan64;
455455
else
@@ -469,7 +469,7 @@ DemandedFields getDemanded(const MachineInstr &MI, const RISCVSubtarget *ST) {
469469

470470
if (RISCVII::hasVLOp(MI.getDesc().TSFlags)) {
471471
const MachineOperand &VLOp = MI.getOperand(getVLOpNum(MI));
472-
// A slidedown/slideup with an *undefined* merge op can freely clobber
472+
// A slidedown/slideup with an *undefined* passthru can freely clobber
473473
// elements not copied from the source vector (e.g. masked off, tail, or
474474
// slideup's prefix). Notes:
475475
// * We can't modify SEW here since the slide amount is in units of SEW.
@@ -478,7 +478,7 @@ DemandedFields getDemanded(const MachineInstr &MI, const RISCVSubtarget *ST) {
478478
// * The LMUL1 restriction is for machines whose latency may depend on VL.
479479
// * As above, this is only legal for tail "undefined" not "agnostic".
480480
if (isVSlideInstr(MI) && VLOp.isImm() && VLOp.getImm() == 1 &&
481-
hasUndefinedMergeOp(MI)) {
481+
hasUndefinedPassthru(MI)) {
482482
Res.VLAny = false;
483483
Res.VLZeroness = true;
484484
Res.LMUL = DemandedFields::LMULLessThanOrEqualToM1;
@@ -492,7 +492,7 @@ DemandedFields getDemanded(const MachineInstr &MI, const RISCVSubtarget *ST) {
492492
// careful to not increase the number of active vector registers (unlike for
493493
// vmv.s.x.)
494494
if (isScalarSplatInstr(MI) && VLOp.isImm() && VLOp.getImm() == 1 &&
495-
hasUndefinedMergeOp(MI)) {
495+
hasUndefinedPassthru(MI)) {
496496
Res.LMUL = DemandedFields::LMULLessThanOrEqualToM1;
497497
Res.SEWLMULRatio = false;
498498
Res.VLAny = false;
@@ -1000,7 +1000,7 @@ RISCVInsertVSETVLI::computeInfoForInstr(const MachineInstr &MI) const {
10001000

10011001
bool TailAgnostic = true;
10021002
bool MaskAgnostic = true;
1003-
if (!hasUndefinedMergeOp(MI)) {
1003+
if (!hasUndefinedPassthru(MI)) {
10041004
// Start with undisturbed.
10051005
TailAgnostic = false;
10061006
MaskAgnostic = false;

0 commit comments

Comments
 (0)