This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE] Extend svdup->insertelement instcombine pattern to support ...
AbandonedPublic

Authored by peterwaller-arm on May 4 2021, 1:41 AM.

Details

Summary

ptrue patterns other other than VL1.

The current algorithm identifies svdup intrinsic calls where the
predicate is a ptrue with the pattern VL1. It is possible to also
perform this optimisation for ptrue patterns in the range VL1 to VL8
inclusive.

Suppose we have a svdup intrinsic call:

svdup (vec, (ptrue pat), elm)

If pat is VL1, we perform the optimisation as before. Else, if pat is in
the range VL2 to VL8 inclusive, we check that the only uses of this
svdup are other svdups that overwrite every vector element except for
one -- if so, we can replace the svdup call with an insertelement
instruction. In any other case, we bail out.

Diff Detail

Event Timeline

joechrisellis created this revision.May 4 2021, 1:41 AM
joechrisellis requested review of this revision.May 4 2021, 1:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2021, 1:41 AM
joechrisellis planned changes to this revision.May 4 2021, 1:55 AM

Bugfix: check that UserPg's intrinsic ID is a ptrue, otherwise we crash in some circumstances.

efriedma added inline comments.May 4 2021, 11:14 AM
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
392

Instead of checking for this specific pattern, can we leverage simplifyDemandedVectorEltsIntrinsic? I guess that doesn't currently work with scalable vectors, though...

joechrisellis marked an inline comment as done.May 5 2021, 2:17 AM
joechrisellis added inline comments.
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
392

I'm not sure -- that function doesn't seem to have an override for AArch64 at the moment. Perhaps something for a different patch. 🙂

peterwaller-arm added inline comments.May 6 2021, 3:19 AM
llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-dup.ll
172

Where are the multiple users?

joechrisellis marked 2 inline comments as done.

Address review comments.

  • @peterwaller-arm:
    • better name for existing test.
    • add a new test to defend against behaviour when there are multiple users of a DUP.
Matt added a subscriber: Matt.May 7 2021, 8:25 AM
peterwaller-arm accepted this revision.May 12 2021, 7:24 AM
This revision is now accepted and ready to land.May 12 2021, 7:24 AM
peterwaller-arm commandeered this revision.Jul 19 2021, 5:01 AM
peterwaller-arm edited reviewers, added: joechrisellis; removed: peterwaller-arm.

Thanks for your work on this @joechrisellis! Much appreciated. Commandeering to abandon, superseded by D106265.

This revision now requires review to proceed.Jul 19 2021, 5:01 AM
peterwaller-arm abandoned this revision.Jul 19 2021, 5:02 AM

Superseded by D106265.