Skip to content

Commit 84d4618

Browse files
committed
[RISCV] Fix the check assertion in hasMergeOp and hasMaskOp
Because we have STRICT_FCVT_W_RV64 equal to ISD::FIRST_TARGET_STRICTFP_OPCODE, the check needs to be splitted into 2 parts. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D155683
1 parent 11a02de commit 84d4618

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4726,9 +4726,12 @@ static unsigned getRISCVVLOp(SDValue Op) {
47264726
/// Return true if a RISC-V target specified op has a merge operand.
47274727
static bool hasMergeOp(unsigned Opcode) {
47284728
assert(Opcode > RISCVISD::FIRST_NUMBER &&
4729-
Opcode <= RISCVISD::STRICT_VFROUND_NOEXCEPT_VL &&
4729+
Opcode <= RISCVISD::LAST_RISCV_STRICTFP_OPCODE &&
47304730
"not a RISC-V target specific op");
4731-
assert(RISCVISD::STRICT_VFROUND_NOEXCEPT_VL - RISCVISD::FIRST_NUMBER == 421 &&
4731+
assert(RISCVISD::LAST_VL_VECTOR_OP - RISCVISD::FIRST_VL_VECTOR_OP == 122 &&
4732+
RISCVISD::LAST_RISCV_STRICTFP_OPCODE -
4733+
ISD::FIRST_TARGET_STRICTFP_OPCODE ==
4734+
21 &&
47324735
"adding target specific op should update this function");
47334736
if (Opcode >= RISCVISD::ADD_VL && Opcode <= RISCVISD::FMAXNUM_VL)
47344737
return true;
@@ -4744,9 +4747,12 @@ static bool hasMergeOp(unsigned Opcode) {
47444747
/// Return true if a RISC-V target specified op has a mask operand.
47454748
static bool hasMaskOp(unsigned Opcode) {
47464749
assert(Opcode > RISCVISD::FIRST_NUMBER &&
4747-
Opcode <= RISCVISD::STRICT_VFROUND_NOEXCEPT_VL &&
4750+
Opcode <= RISCVISD::LAST_RISCV_STRICTFP_OPCODE &&
47484751
"not a RISC-V target specific op");
4749-
assert(RISCVISD::STRICT_VFROUND_NOEXCEPT_VL - RISCVISD::FIRST_NUMBER == 421 &&
4752+
assert(RISCVISD::LAST_VL_VECTOR_OP - RISCVISD::FIRST_VL_VECTOR_OP == 122 &&
4753+
RISCVISD::LAST_RISCV_STRICTFP_OPCODE -
4754+
ISD::FIRST_TARGET_STRICTFP_OPCODE ==
4755+
21 &&
47504756
"adding target specific op should update this function");
47514757
if (Opcode >= RISCVISD::TRUNCATE_VECTOR_VL && Opcode <= RISCVISD::SETCC_VL)
47524758
return true;

llvm/lib/Target/RISCV/RISCVISelLowering.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,11 @@ enum NodeType : unsigned {
143143
SM3P0, SM3P1,
144144

145145
// Vector Extension
146+
FIRST_VL_VECTOR_OP,
146147
// VMV_V_V_VL matches the semantics of vmv.v.v but includes an extra operand
147148
// for the VL value to be used for the operation. The first operand is
148149
// passthru operand.
149-
VMV_V_V_VL,
150+
VMV_V_V_VL = FIRST_VL_VECTOR_OP,
150151
// VMV_V_X_VL matches the semantics of vmv.v.x but includes an extra operand
151152
// for the VL value to be used for the operation. The first operand is
152153
// passthru operand.
@@ -166,8 +167,6 @@ enum NodeType : unsigned {
166167
// expanded late to two scalar stores and a stride 0 vector load.
167168
// The first operand is passthru operand.
168169
SPLAT_VECTOR_SPLIT_I64_VL,
169-
// Read VLENB CSR
170-
READ_VLENB,
171170
// Truncates a RVV integer vector by one power-of-two. Carries both an extra
172171
// mask and VL operand.
173172
TRUNCATE_VECTOR_VL,
@@ -360,6 +359,10 @@ enum NodeType : unsigned {
360359
// vfirst.m with additional mask and VL operands.
361360
VFIRST_VL,
362361

362+
LAST_VL_VECTOR_OP = VFIRST_VL,
363+
364+
// Read VLENB CSR
365+
READ_VLENB,
363366
// Reads value of CSR.
364367
// The first operand is a chain pointer. The second specifies address of the
365368
// required CSR. Two results are produced, the read value and the new chain
@@ -405,6 +408,7 @@ enum NodeType : unsigned {
405408
STRICT_FSETCC_VL,
406409
STRICT_FSETCCS_VL,
407410
STRICT_VFROUND_NOEXCEPT_VL,
411+
LAST_RISCV_STRICTFP_OPCODE = STRICT_VFROUND_NOEXCEPT_VL,
408412

409413
// WARNING: Do not add anything in the end unless you want the node to
410414
// have memop! In fact, starting from FIRST_TARGET_MEMORY_OPCODE all

0 commit comments

Comments
 (0)