This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][RISCVISelLowering] Add tail agnostic policy operand to VECREDUCE instructions
ClosedPublic

Authored by nitinjohnraj on Mar 23 2023, 1:01 PM.

Details

Summary

vp.reduce.or currently generates a TU vsetvli because we need to send a tied operand for vd to support vl=0 but we don’t have any way to indictate that we only care about element 0.

To fix this we need to provide a policy operand to the reduction pseudoinstructions. The isel patterns for intrinsics can set the policy to tail undisturbed.

All of these RISCVISD opcodes will need to have a policy operand added wherever they are created.

VECREDUCE_ADD_VL,                                                              
VECREDUCE_UMAX_VL,                                                             
VECREDUCE_SMAX_VL,                                                             
VECREDUCE_UMIN_VL,                                                             
VECREDUCE_SMIN_VL,                                                             
VECREDUCE_AND_VL,                                                              
VECREDUCE_OR_VL,                                                               
VECREDUCE_XOR_VL,                                                              
VECREDUCE_FADD_VL,                                                             
VECREDUCE_SEQ_FADD_VL,                                                         
VECREDUCE_FMIN_VL,                                                             
VECREDUCE_FMAX_VL,

Diff Detail

Event Timeline

nitinjohnraj created this revision.Mar 23 2023, 1:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 1:01 PM
nitinjohnraj requested review of this revision.Mar 23 2023, 1:01 PM
nitinjohnraj edited the summary of this revision. (Show Details)Mar 23 2023, 1:03 PM
nitinjohnraj added a reviewer: craig.topper.
craig.topper added inline comments.Mar 23 2023, 3:03 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
6287

Remove the 6 from the brackets. Let the compiler autodetect the size.

8704

Same here

llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
4920

Reduce indentation to line op2_type with intrinsic from previous line

4923

Same here

5030–5031

Same here

5038–5039

Indent 2 more spaces

5052–5053

Same here

llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
1939

ARe there still users of the old VPatReductionVL class?

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-reduction-fp-vp.ll
14

We should not be using mu here. It appears the switch to VPseudoTernaryWithPolicy caused us to get let UsesMaskPolicy=1 for these instructions. VPseudoTernary used VPseudoBinaryMask which does not set the UsesMaskPolicy=1

nitinjohnraj marked 8 inline comments as done.

Fixed so that the policy for vecreduce instructions is ta, ma + some refactoring

llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
1939

Seems like the answer is no. I've removed it and renamed VPatReductionVL_Policy to VPatReductionVL.

This revision is now accepted and ready to land.Mar 24 2023, 1:59 PM
This revision was landed with ongoing or failed builds.Mar 25 2023, 2:47 AM
This revision was automatically updated to reflect the committed changes.