[llvm] 709ba08 - [RISCV] Use RISCVII::getVecPolicyOpNum instead of making assumptions. NFC (#144175)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 13 22:18:15 PDT 2025
Author: Craig Topper
Date: 2025-06-13T22:18:12-07:00
New Revision: 709ba084c5632b786f2e6c503d3f9f27e1f1c433
URL: https://github.com/llvm/llvm-project/commit/709ba084c5632b786f2e6c503d3f9f27e1f1c433
DIFF: https://github.com/llvm/llvm-project/commit/709ba084c5632b786f2e6c503d3f9f27e1f1c433.diff
LOG: [RISCV] Use RISCVII::getVecPolicyOpNum instead of making assumptions. NFC (#144175)
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 107f645709c70..7d868bf6e2ab0 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -3696,7 +3696,8 @@ bool RISCVInstrInfo::findCommutedOpIndices(const MachineInstr &MI,
case CASE_VMA_OPCODE_LMULS(NMSAC, VV): {
// If the tail policy is undisturbed we can't commute.
assert(RISCVII::hasVecPolicyOp(MI.getDesc().TSFlags));
- if ((MI.getOperand(MI.getNumExplicitOperands() - 1).getImm() & 1) == 0)
+ if ((MI.getOperand(RISCVII::getVecPolicyOpNum(MI.getDesc())).getImm() &
+ 1) == 0)
return false;
// For these instructions we can only swap operand 1 and operand 3 by
@@ -3716,7 +3717,8 @@ bool RISCVInstrInfo::findCommutedOpIndices(const MachineInstr &MI,
case CASE_VMA_OPCODE_LMULS(NMSUB, VV): {
// If the tail policy is undisturbed we can't commute.
assert(RISCVII::hasVecPolicyOp(MI.getDesc().TSFlags));
- if ((MI.getOperand(MI.getNumExplicitOperands() - 1).getImm() & 1) == 0)
+ if ((MI.getOperand(RISCVII::getVecPolicyOpNum(MI.getDesc())).getImm() &
+ 1) == 0)
return false;
// For these instructions we have more freedom. We can commute with the
@@ -4331,7 +4333,8 @@ MachineInstr *RISCVInstrInfo::convertToThreeAddress(MachineInstr &MI,
// If the tail policy is undisturbed we can't convert.
assert(RISCVII::hasVecPolicyOp(MI.getDesc().TSFlags) &&
MI.getNumExplicitOperands() == 6);
- if ((MI.getOperand(5).getImm() & 1) == 0)
+ if ((MI.getOperand(RISCVII::getVecPolicyOpNum(MI.getDesc())).getImm() &
+ 1) == 0)
return nullptr;
// clang-format off
More information about the llvm-commits
mailing list