Skip to content

Commit a841099

Browse files
committed
[RISCV][VLOPT] Fix operand check in isVectorOpUsedAsScalarOp
A reduction instruction always has a passthru operand, so the scalar operand should always be vs1 which is at index 3. Even though the destination operand is also scalar, I think the passthru will need to preserve all elements so I haven't included it.
1 parent 2057a45 commit a841099

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,10 +611,8 @@ static bool isVectorOpUsedAsScalarOp(MachineOperand &MO) {
611611
case RISCV::VFREDOSUM_VS:
612612
case RISCV::VFREDUSUM_VS:
613613
case RISCV::VFWREDOSUM_VS:
614-
case RISCV::VFWREDUSUM_VS: {
615-
bool HasPassthru = RISCVII::isFirstDefTiedToFirstUse(MI->getDesc());
616-
return HasPassthru ? MO.getOperandNo() == 2 : MO.getOperandNo() == 3;
617-
}
614+
case RISCV::VFWREDUSUM_VS:
615+
return MO.getOperandNo() == 3;
618616
default:
619617
return false;
620618
}

llvm/test/CodeGen/RISCV/rvv/vl-opt.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ body: |
2525
; CHECK: liveins: $x1
2626
; CHECK-NEXT: {{ $}}
2727
; CHECK-NEXT: %vl:gprnox0 = COPY $x1
28-
; CHECK-NEXT: %x:vr = PseudoVADD_VV_M1 $noreg, $noreg, $noreg, %vl, 5 /* e32 */, 0 /* tu, mu */
28+
; CHECK-NEXT: %x:vr = PseudoVADD_VV_M1 $noreg, $noreg, $noreg, -1, 5 /* e32 */, 0 /* tu, mu */
2929
; CHECK-NEXT: %y:vr = PseudoVREDSUM_VS_M1_E64 $noreg, %x, $noreg, -1, 6 /* e64 */, 0 /* tu, mu */
3030
; CHECK-NEXT: %z:vr = PseudoVADD_VV_M1 $noreg, %x, $noreg, %vl, 5 /* e32 */, 0 /* tu, mu */
3131
%vl:gprnox0 = COPY $x1

0 commit comments

Comments
 (0)