This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE][InstCombine] Unpack of a splat vector -> Scalar extend
ClosedPublic

Authored by mnadeem on Jul 27 2021, 6:19 PM.

Details

Summary

Replace vector unpack operation with a scalar extend operation.

unpack(splat(X)) --> splat(extend(X))

If we have both, unpkhi and unpklo, for the same vector then we may
save a register in some cases, e.g:

Hi = unpkhi (splat(X))
Lo = unpklo(splat(X)) 
 --> Hi = Lo = splat(extend(X))

Diff Detail

Event Timeline

mnadeem created this revision.Jul 27 2021, 6:19 PM
mnadeem requested review of this revision.Jul 27 2021, 6:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2021, 6:19 PM
mnadeem updated this revision to Diff 362270.Jul 27 2021, 8:49 PM
Matt added a subscriber: Matt.Jul 28 2021, 2:48 PM
paulwalker-arm added inline comments.Jul 30 2021, 4:14 AM
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
813

Can this use Builder.CreateVectorSplat? or is getScalableSplat doing something special?

mnadeem updated this revision to Diff 363604.Aug 2 2021, 4:41 PM
mnadeem retitled this revision from [AArch64][SVE][InstCombine] Unpack of a splat vector to [AArch64][SVE][InstCombine] Unpack of a splat vector -> Scalar extend.
mnadeem edited the summary of this revision. (Show Details)
  • Use Builder.CreateVectorSplat(...) instead of using custom code to create splat.
mnadeem marked an inline comment as done.Aug 2 2021, 4:42 PM
mnadeem added inline comments.
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
813

Replaced with CreateVectorSplat.

mnadeem marked an inline comment as done.Aug 2 2021, 4:42 PM
paulwalker-arm added inline comments.Aug 3 2021, 9:41 AM
llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-unpkhi-unpklo.ll
2

Please use utils/update_test_checks.py to generate the CHECK lines.

27

The test is called uunpklo_splat but the IR is calling uunpkhi.

32–50

This looks like a redundant test which is not testing anything that is not already covered by the separate unsigned hi/lo tests.

73

The test is called sunpklo_splat but the IR is calling sunpkhi.

78–96

As above, this looks like a redundant test which is not testing anything that is not already covered by the separate signed hi/lo tests.

100–103

These should end .nxv4i32 to match the return type.

mnadeem updated this revision to Diff 364659.Aug 5 2021, 5:28 PM

Fixed tests according to the comments.

mnadeem updated this revision to Diff 364661.Aug 5 2021, 5:31 PM
paulwalker-arm accepted this revision.Aug 6 2021, 2:49 AM
This revision is now accepted and ready to land.Aug 6 2021, 2:49 AM
This revision was landed with ongoing or failed builds.Aug 9 2021, 3:00 PM
This revision was automatically updated to reflect the committed changes.