HomePhabricator

[PowerPC] Canonicalize shuffles to match more single-instruction masks on LE

Authored by nemanjai on Jun 18 2020, 7:53 PM.

Description

[PowerPC] Canonicalize shuffles to match more single-instruction masks on LE

We currently miss a number of opportunities to emit single-instruction
VMRG[LH][BHW] instructions for shuffles on little endian subtargets. Although
this in itself is not a huge performance opportunity since loading the permute
vector for a VPERM can always be pulled out of loops, producing such merge
instructions is useful to downstream optimizations.
Since VPERM is essentially opaque to all subsequent optimizations, we want to
avoid it as much as possible. Other permute instructions have semantics that can
be reasoned about much more easily in later optimizations.

This patch does the following:

  • Canonicalize shuffles so that the first element comes from the first vector (since that's what most of the mask matching functions want)
  • Switch the elements that come from splat vectors so that they match the corresponding elements from the other vector (to allow for merges)
  • Adds debugging messages for when a shuffle is matched to a VPERM so that anyone interested in improving this further can get the info for their code

Differential revision: https://reviews.llvm.org/D77448