This is an archive of the discontinued LLVM Phabricator instance.

[CostModel] Replace ShuffleKind::SK_Alternate with ShuffleKind::SK_Select (PR33744)
ClosedPublic

Authored by RKSimon on Jun 9 2018, 11:48 AM.

Details

Summary

As discussed on PR33744, this patch replaces ShuffleKind::SK_Alternate which requires shuffle masks to only match an alternating pattern from its 2 sources:

e.g. v4f32: <0,5,2,7> or <4,1,6,3>

This seems far too restrictive as most SIMD hardware which will implement it using a general blend/bit-select instruction (permitting elements from either source as long as they are inline):

e.g. v4f32: <0,5,2,7>, <4,1,6,3>, <0,1,6,7>, <4,1,2,3> etc.

This initial patch just updates the name and cost model shuffle mask analysis, later patch reviews will update SLP to better utilise this - it still limits itself to SK_Alternate patterns.

It also raised an interesting issue in that Identity shuffles are being matched by analysis to a mixture of SK_PermuteSingleSrc/SK_Alternate - shouldn't we just return cost = 0 for these cases?

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Jun 9 2018, 11:48 AM
spatel accepted this revision.Jun 12 2018, 8:38 AM

LGTM.

include/llvm/Analysis/TargetTransformInfo.h
644 ↗(On Diff #150946)

A bit more description would be good here. Something like:
Selects elements from the corresponding lane of one source operand or the other. This is equivalent to a vector select with a constant condition operand.

lib/Analysis/TargetTransformInfo.cpp
678 ↗(On Diff #150946)

Formatting: IsSelect.

This revision is now accepted and ready to land.Jun 12 2018, 8:38 AM
This revision was automatically updated to reflect the committed changes.