This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Generalize performFP_TO_INTCombine to vectors
ClosedPublic

Authored by luke on Jan 12 2023, 4:25 AM.

Details

Summary

Like in the scalar domain, combine calls to (fp_to_int (ftrunc X)) on
scalable and fixed-length vectors into a single vfcvt instruction.
For truncating rounds, the static vfcvt.rtz rounding mode is used.
Otherwise use the VFCVT_RM_ variants to set the rounding mode
dynamically.
Closes https://github.com/llvm/llvm-project/issues/56737

Diff Detail

Event Timeline

luke created this revision.Jan 12 2023, 4:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 4:25 AM
luke requested review of this revision.Jan 12 2023, 4:25 AM
luke updated this revision to Diff 488600.Jan 12 2023, 4:27 AM

Don't include test case commit

luke added inline comments.Jan 12 2023, 4:30 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
1919

Is this correct?

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

I noticed the unsigned variants of some of the conversion instructions were missing, so I've added them in here since they're generated by the combine. Not sure if their absence is intentional or not.

luke edited the summary of this revision. (Show Details)Jan 12 2023, 4:31 AM
craig.topper added inline comments.Jan 12 2023, 11:28 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
9577

You're only handling f16->i16 f32->i32 and f64->i64, but you didn't check that the integer size is the same as FP.

9580

Need to check that VT is a legal type.

luke updated this revision to Diff 489037.Jan 13 2023, 9:16 AM
luke marked an inline comment as not done.

Check for legal types and equal int/float bit sizes

luke added inline comments.Jan 13 2023, 9:20 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
9577

Whoops, presumably this means that we can handle f16 -> i32 with vfwcvt.xu.f.v, f32 -> i16 with vfncvt.xu.f.v and so on?

luke marked 2 inline comments as done.Jan 13 2023, 9:20 AM
This revision is now accepted and ready to land.Jan 17 2023, 9:04 AM
This revision was landed with ongoing or failed builds.Jan 18 2023, 2:53 AM
This revision was automatically updated to reflect the committed changes.