This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Remove SEW=8 case for floating-point
ClosedPublic

Authored by pcwang-thead on Apr 14 2023, 2:48 AM.

Details

Summary

For floating-point instructions, SEW won't be 8. So we don't need
to generate scheduling resources for it.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2023, 2:48 AM
pcwang-thead requested review of this revision.Apr 14 2023, 2:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2023, 2:48 AM

Thanks for working on this. I was going to add a similar patch today!

llvm/lib/Target/RISCV/RISCVScheduleV.td
39

Under the vector specification, what does it mean for a vector floating point instruction to execute under MF8? Is this allowed?

In our scheduler, what does it mean for a vector floating point pseudo to be MF8? Under this implementation, does it mean we do not define scheduling resources for it since sew set is empty?

I wonder whether we need a MxListF that does not contain MF8, if it is the case that floating point vector instructions under MF8 don't make sense.

llvm/lib/Target/RISCV/RISCVScheduleV.td
39

Under the vector specification, what does it mean for a vector floating point instruction to execute under MF8? Is this allowed?

My understanding is:

  1. SEW=8 is illegal since there is no standard 8 bits floating point format currently.
  2. The spec (3.4.2. Vector Register Grouping) says:
In general, the requirement is to support LMUL ≥ SEWMIN/ELEN, where SEWMIN is the narrowest supported SEW value and ELEN is the widest supported SEW value.
When LMUL < SEWMIN/ELEN, there is no guarantee an implementation would have enough bits in the fractional vector register to store at least one element, as VLEN=ELEN is a valid implementation choice. For example, with VLEN=ELEN=32, and SEW MIN=8, an LMUL of 1/8 would only provide four bits of storage in a vector register.
  1. MF8 may be legal, but it depends on VLEN. So, as you can see, there is no mf8 types in C API(Data Types) and LLVM IR (Vector type mapping to LLVM types).

In our scheduler, what does it mean for a vector floating point pseudo to be MF8? Under this implementation, does it mean we do not define scheduling resources for it since sew set is empty?

Yes, we won't define any scheduling resources for it as we won't generate MF8 pseudos(see https://github.com/llvm/llvm-project/blob/9fdf82dc32dc38e0b92dab3215a83d8f3c2f9bbf/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td#L112).

I wonder whether we need a MxListF that does not contain MF8, if it is the case that floating point vector instructions under MF8 don't make sense.

It makes sense to me to add a MxListF. I keep the MF8 case in SchedSEWSetF just because there is no MxList parameter in LMULSEWWriteResImpl and LMULSEWReadAdvanceImpl(we iterate over SchedMxList). A !exist can be added just like LMULWriteResImpl and LMULReadAdvanceImpl.

llvm/lib/Target/RISCV/RISCVScheduleV.td
39

Nope……
We can't use !exists since we need to get sews first.

llvm/lib/Target/RISCV/RISCVScheduleV.td
39
multiclass LMULSEWWriteResImpl<string name, list<ProcResourceKind> resources,
                               bit isF = 0> {
  def : WriteRes<!cast<SchedWrite>(name # "_WorstCase"), resources>;
  // Now I think we can remove MF8 from SchedSEWSetF
  foreach mx = !if(isF, SchedMxListF, SchedMxList) in {
    defvar sews = !if(isF, SchedSEWSetF<mx>.val, SchedSEWSet<mx>.val); 
    foreach sew = sews in
      def : WriteRes<!cast<SchedWrite>(name # "_" # mx # "_E" # sew), resources>;
  }
}
  • Rebase.
  • Add SchedMxListF.
pcwang-thead marked 2 inline comments as done.Apr 17 2023, 8:11 PM
pcwang-thead retitled this revision from [RISCV] Remove SEW=8 case for floating point to [RISCV] Remove SEW=8 case for floating-point.
pcwang-thead edited the summary of this revision. (Show Details)

LGTM but I'll let @michaelmaitland give final approval

This revision is now accepted and ready to land.Apr 18 2023, 6:03 AM
This revision was landed with ongoing or failed builds.Apr 18 2023, 7:46 PM
This revision was automatically updated to reflect the committed changes.