Skip to content

Commit

Permalink
[RISCV] Factor out a dupiicate bit of repeated code in performCombine…
Browse files Browse the repository at this point in the history
…VMergeAndVOps [nfc]

We have the SEW operand access repeating in all paths, common it up to make the code easier to read.

This is a subset of Luke's D155063.  I'm splitting pieces and landing them in the process of convincing myself all the individual transforms are in fact correct.
  • Loading branch information
preames committed Jul 13, 2023
1 parent 1fa4a0a commit ca8ef82
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3329,17 +3329,19 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
"Expected instructions with mask have a tied dest.");
#endif

SDValue SEW = True.getOperand(TrueVLIndex + 1);

uint64_t Policy = isImplicitDef(N->getOperand(0)) ?
RISCVII::TAIL_AGNOSTIC : /*TUMU*/ 0;
SDValue PolicyOp =
CurDAG->getTargetConstant(Policy, DL, Subtarget->getXLenVT());


SmallVector<SDValue, 8> Ops;
if (IsMasked) {
Ops.push_back(False);
Ops.append(True->op_begin() + 1, True->op_begin() + TrueVLIndex);
Ops.append({VL, /* SEW */ True.getOperand(TrueVLIndex + 1)});
Ops.push_back(PolicyOp);
Ops.append({VL, SEW, PolicyOp});
Ops.append(True->op_begin() + TrueVLIndex + 3, True->op_end());
} else {
Ops.push_back(False);
Expand All @@ -3351,12 +3353,11 @@ bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
SDValue RoundMode = True->getOperand(TrueVLIndex - 1);
Ops.append(True->op_begin() + HasTiedDest,
True->op_begin() + TrueVLIndex - 1);
Ops.append(
{Mask, RoundMode, VL, /* SEW */ True.getOperand(TrueVLIndex + 1)});
Ops.append({Mask, RoundMode, VL, SEW});
} else {
Ops.append(True->op_begin() + HasTiedDest,
True->op_begin() + TrueVLIndex);
Ops.append({Mask, VL, /* SEW */ True.getOperand(TrueVLIndex + 1)});
Ops.append({Mask, VL, SEW});
}
Ops.push_back(PolicyOp);

Expand Down

0 comments on commit ca8ef82

Please sign in to comment.