This is an archive of the discontinued LLVM Phabricator instance.

[SVE][CodeGen] Fix legalisation for scalable types
ClosedPublic

Authored by kmclaughlin on Apr 24 2020, 9:13 AM.

Details

Summary

This patch handles illegal scalable types when lowering IR operations,
addressing several places where the value of isScalableVector() is
ignored.

For types such as <vscale x 8 x i32>, this means splitting the
operations. In this example, we would split it into two
operations of type <vscale x 4 x i32> for the low and high halves.

In cases such as <vscale x 2 x i32>, the elements in the vector
will be promoted. In this case they will be promoted to
i64 (with a vector of type <vscale x 2 x i64>)

Diff Detail

Event Timeline

kmclaughlin created this revision.Apr 24 2020, 9:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2020, 9:13 AM
efriedma added inline comments.Apr 24 2020, 1:04 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
738

Can we use ElementCount here?

llvm/lib/CodeGen/TargetLoweringBase.cpp
1427

Can we use ElementCount here?

llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
107

Maybe also worth adding a testcase for <vscale x 1 x i64>, assuming that doesn't expose anything really tricky.

  • Use ElementCount with getVectorVT
kmclaughlin marked 2 inline comments as done.Apr 28 2020, 6:07 AM
kmclaughlin added inline comments.
llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
107

Promotion is not possible for <vscale x 1 x i64> since this would result in a <vscale x 1 x i128>, which is also illegal. Instead will need to widen a type such as <vscale x 1 x i64>, which needs some more work. For fixed width vectors, the compiler will scalarise cases such as this (e.g. from 1 x i32 to just i32), which isn't something we can do for scalable vectors because of the runtime scaling.
This has never had much priority because in practice the vectoriser won't pick a VF of 1, so I think we can add support for this at a later point. Currently, tests which use types such as this will trigger the assert added to FoldBUILD_VECTOR in D78636.

kmclaughlin marked an inline comment as done.Apr 28 2020, 10:36 AM
kmclaughlin added inline comments.
llvm/lib/CodeGen/TargetLoweringBase.cpp
1429

I will create a separate patch to clean this up a bit by adding an overloaded operator>>

efriedma accepted this revision.May 6 2020, 9:14 AM

LGTM

This revision is now accepted and ready to land.May 6 2020, 9:14 AM
This revision was automatically updated to reflect the committed changes.