This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add support for fixed vector reductions.
ClosedPublic

Authored by craig.topper on Mar 5 2021, 10:09 PM.

Details

Summary

I've included tests that require type legalization to split the
vector. The i64 version of these scalarizes on RV32 due to type
legalization visiting the result before the vector type. So we
have to abort our custom expansion to avoid creating target
specific nodes with an illegal type. Then type legalization ends
up scalarizing. We might be able to fix this by doing custom
splitting for large vectors in our handler to get down to a legal
type.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 5 2021, 10:09 PM
craig.topper requested review of this revision.Mar 5 2021, 10:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2021, 10:09 PM
Herald added a subscriber: MaskRay. · View Herald Transcript

clang-format

Harbormaster completed remote builds in B92460: Diff 328733.

Wow yeah that's some heavy scalarization. I think I came across some situations where custom vector legalization may be required, as you say. It just felt odd, though. Do any other targets have to do this, other than simple hi/lo splitting?

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
2453

This (and further down) can now be simplified to = getContainerForFixedLengthVector(VecVT); (after rebasing)

Wow yeah that's some heavy scalarization. I think I came across some situations where custom vector legalization may be required, as you say. It just felt odd, though. Do any other targets have to do this, other than simple hi/lo splitting?

Only 3 targets use the VECREDUCE nodes today, AArch64, ARM, and RISCV. X86 does not use them yet. AArch64 doesn't have this problem because their largest integer type is their largest vector element type. ARM doesn't appear to support i64 reductions.

frasercrmck accepted this revision.Mar 9 2021, 2:12 AM

Only 3 targets use the VECREDUCE nodes today, AArch64, ARM, and RISCV. X86 does not use them yet. AArch64 doesn't have this problem because their largest integer type is their largest vector element type. ARM doesn't appear to support i64 reductions.

Ah right okay, thanks. Anyway, the changes LGTM. I don't know if the size of the test files is a problem. It's not unprecedented but it still makes me uncomfortable.

This revision is now accepted and ready to land.Mar 9 2021, 2:12 AM
This revision was automatically updated to reflect the committed changes.
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-reduction-fp.ll