Page MenuHomePhabricator

[LoopVectorizer] NFC: Remove unnecessary asserts that VF cannot be scalable.
ClosedPublic

Authored by sdesmalen on Nov 9 2020, 2:28 AM.

Details

Summary

This patch removes a number of asserts that VF is not scalable, even though
the code where this assert lives does nothing that prevents VF being scalable.

Diff Detail

Event Timeline

sdesmalen created this revision.Nov 9 2020, 2:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 9 2020, 2:28 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
sdesmalen requested review of this revision.Nov 9 2020, 2:28 AM

As far as I can tell these do sound OK, except perhaps for the one I put a question on.

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
5102

What happens if this function returns true? Do (predicated) scalars work OK for scalable vectors.

sdesmalen added inline comments.Nov 17 2020, 4:41 AM
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
5102

If this function returns true, the operation would have to be scalarized. For scalable vectors, scalarization is only supported if the value is uniform after vectorization, so it can extract the first or last element. Scalarizing a non-uniform value is not supported, because there is currently no way to expand to a scalarization loop (and even if there would be, we probably wouldn't want to).

From the comment in collectLoopUniforms (above addToWorklistIfAllowed), it seems that when isScalarWithPredication returns true, the value cannot be uniform. This means that the cost-model/legalization should prevent this from happening for scalable vectors. This is one of the reasons we're adding a new cost class in D91174 so that it would never pick a scalable VF when scalarization is required.

There are currently other asserts that guard this case from happening, like in VPReplicateRecipe::execute.

dmgreen accepted this revision.Nov 24 2020, 8:29 AM

LGTM.

This revision is now accepted and ready to land.Nov 24 2020, 8:29 AM
This revision was landed with ongoing or failed builds.Dec 9 2020, 3:26 AM
This revision was automatically updated to reflect the committed changes.