[llvm] [RISCV][VLOpt] Consolidate EMUL=SEW/EEW*LMUL logic [NFC] (PR #122021)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 7 21:42:08 PST 2025
================
@@ -721,16 +708,48 @@ static OperandInfo getOperandInfo(const MachineOperand &MO,
case RISCV::VREDOR_VS:
case RISCV::VREDSUM_VS:
case RISCV::VREDXOR_VS: {
- if (MO.getOperandNo() == 2)
- return OperandInfo(MIVLMul, MILog2SEW);
- return OperandInfo(MILog2SEW);
+ return MILog2SEW;
}
default:
return {};
}
}
+static OperandInfo getOperandInfo(const MachineOperand &MO,
+ const MachineRegisterInfo *MRI) {
+ const MachineInstr &MI = *MO.getParent();
+ const RISCVVPseudosTable::PseudoInfo *RVV =
+ RISCVVPseudosTable::getPseudoInfo(MI.getOpcode());
+ assert(RVV && "Could not find MI in PseudoTable");
+
+ std::optional<unsigned> Log2EEW = getOperandLog2EEW(MO, MRI);
+ if (!Log2EEW)
+ return {};
+
+ switch (RVV->BaseInstr) {
+ // Vector Reduction Operations
+ // Vector Single-Width Integer Reduction Instructions
+ // The Dest and VS1 only read element 0 of the vector register. Return just
+ // the EEW for these.
+ case RISCV::VREDAND_VS:
+ case RISCV::VREDMAX_VS:
+ case RISCV::VREDMAXU_VS:
+ case RISCV::VREDMIN_VS:
+ case RISCV::VREDMINU_VS:
+ case RISCV::VREDOR_VS:
+ case RISCV::VREDSUM_VS:
+ case RISCV::VREDXOR_VS:
----------------
lukel97 wrote:
This is non-NFC so not for this PR. Do VMV_S_X and VMV_X_S need to be handled here?
And eventually floating point reductions too? I think we can consolidate this with `isVectorOpUsedAsScalarOp`
https://github.com/llvm/llvm-project/pull/122021
More information about the llvm-commits
mailing list