[llvm] [RISCV] Introduce local peephole to reduce VLs based on demanded VL (PR #104689)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 18 08:33:54 PDT 2024
================
@@ -404,33 +476,17 @@ bool RISCVVectorPeephole::foldVMV_V_V(MachineInstr &MI) {
SrcPassthru.getReg() != Passthru.getReg())
return false;
- // Because Src and MI have the same passthru, we can use either AVL as long as
- // it's the smaller of the two.
- //
- // (src pt, ..., vl=5) x x x x x|. . .
- // (vmv.v.v pt, src, vl=3) x x x|. . . . .
- // ->
- // (src pt, ..., vl=3) x x x|. . . . .
- //
- // (src pt, ..., vl=3) x x x|. . . . .
- // (vmv.v.v pt, src, vl=6) x x x . . .|. .
- // ->
- // (src pt, ..., vl=3) x x x|. . . . .
+ // Src VL will have already been reduced if legal (see tryToReduceVL),
+ // so we don't need to handle a smaller source VL here. However, the
+ // user's VL may be larger
MachineOperand &SrcVL = Src->getOperand(RISCVII::getVLOpNum(Src->getDesc()));
const MachineOperand *MinVL = getKnownMinVL(&MI.getOperand(3), &SrcVL);
- if (!MinVL)
- return false;
-
- bool VLChanged = !MinVL->isIdenticalTo(SrcVL);
- bool ActiveElementsAffectResult = RISCVII::activeElementsAffectResult(
- TII->get(RISCV::getRVVMCOpcode(Src->getOpcode())).TSFlags);
-
- if (VLChanged && (ActiveElementsAffectResult || Src->mayRaiseFPException()))
----------------
lukel97 wrote:
Very satisfying to see this generalized. Nit, could you update the comment above `foldVMV_V_V` to reflect that Src's VL doesn't change anymore and that instead we check for MI.VL >= Src.VL
https://github.com/llvm/llvm-project/pull/104689
More information about the llvm-commits
mailing list