[llvm] 5fcb5d7 - [RISCV] Add assertion of hasVecPolicyOp to catch masked intrinsic without policy operand.
Yeting Kuo via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 12 19:09:59 PDT 2022
Author: Yeting Kuo
Date: 2022-09-13T10:09:49+08:00
New Revision: 5fcb5d77599e2b028dd8b7b8a3a7853701838e0c
URL: https://github.com/llvm/llvm-project/commit/5fcb5d77599e2b028dd8b7b8a3a7853701838e0c
DIFF: https://github.com/llvm/llvm-project/commit/5fcb5d77599e2b028dd8b7b8a3a7853701838e0c.diff
LOG: [RISCV] Add assertion of hasVecPolicyOp to catch masked intrinsic without policy operand.
The original code may have incorrect result if there is a masked instruction
without policy operand to make us set its policy to TUMU. The patch adds an
assertion to catch the instruction.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D133302
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index ac57716d5add8..52dd41d7798f6 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -2697,14 +2697,15 @@ bool RISCVDAGToDAGISel::doPeepholeMergeVVMFold() {
SDLoc DL(N);
unsigned MaskedOpc = Info->MaskedPseudo;
+ assert(RISCVII::hasVecPolicyOp(TII->get(MaskedOpc).TSFlags) &&
+ "Expected instructions with mask have policy operand.");
+
SmallVector<SDValue, 8> Ops;
Ops.push_back(Merge);
Ops.append(True->op_begin(), True->op_begin() + TrueVLIndex);
Ops.append({Mask, VL, /* SEW */ True.getOperand(TrueVLIndex + 1)});
-
- if (RISCVII::hasVecPolicyOp(TII->get(MaskedOpc).TSFlags))
- Ops.push_back(
- CurDAG->getTargetConstant(/* TUMU */ 0, DL, Subtarget->getXLenVT()));
+ Ops.push_back(
+ CurDAG->getTargetConstant(/* TUMU */ 0, DL, Subtarget->getXLenVT()));
// Result node should have chain operand of True.
if (HasChainOp)
More information about the llvm-commits
mailing list