@@ -3696,7 +3696,8 @@ bool RISCVInstrInfo::findCommutedOpIndices(const MachineInstr &MI,
3696
3696
case CASE_VMA_OPCODE_LMULS (NMSAC, VV): {
3697
3697
// If the tail policy is undisturbed we can't commute.
3698
3698
assert (RISCVII::hasVecPolicyOp (MI.getDesc ().TSFlags ));
3699
- if ((MI.getOperand (MI.getNumExplicitOperands () - 1 ).getImm () & 1 ) == 0 )
3699
+ if ((MI.getOperand (RISCVII::getVecPolicyOpNum (MI.getDesc ())).getImm () &
3700
+ 1 ) == 0 )
3700
3701
return false ;
3701
3702
3702
3703
// For these instructions we can only swap operand 1 and operand 3 by
@@ -3716,7 +3717,8 @@ bool RISCVInstrInfo::findCommutedOpIndices(const MachineInstr &MI,
3716
3717
case CASE_VMA_OPCODE_LMULS (NMSUB, VV): {
3717
3718
// If the tail policy is undisturbed we can't commute.
3718
3719
assert (RISCVII::hasVecPolicyOp (MI.getDesc ().TSFlags ));
3719
- if ((MI.getOperand (MI.getNumExplicitOperands () - 1 ).getImm () & 1 ) == 0 )
3720
+ if ((MI.getOperand (RISCVII::getVecPolicyOpNum (MI.getDesc ())).getImm () &
3721
+ 1 ) == 0 )
3720
3722
return false ;
3721
3723
3722
3724
// For these instructions we have more freedom. We can commute with the
@@ -4331,7 +4333,8 @@ MachineInstr *RISCVInstrInfo::convertToThreeAddress(MachineInstr &MI,
4331
4333
// If the tail policy is undisturbed we can't convert.
4332
4334
assert (RISCVII::hasVecPolicyOp (MI.getDesc ().TSFlags ) &&
4333
4335
MI.getNumExplicitOperands () == 6 );
4334
- if ((MI.getOperand (5 ).getImm () & 1 ) == 0 )
4336
+ if ((MI.getOperand (RISCVII::getVecPolicyOpNum (MI.getDesc ())).getImm () &
4337
+ 1 ) == 0 )
4335
4338
return nullptr ;
4336
4339
4337
4340
// clang-format off
0 commit comments