Page MenuHomePhabricator

[SLP]Improve reductions analysis and emission, part 1.
Needs ReviewPublic

Authored by ABataev on Thu, Nov 18, 9:29 AM.



Currently SLP vectorizer walks through the instructions and selects
3 main classes of values:

  1. reduction operations - instructions with same reduction opcode (add, mul, min/max, etc.), which build the reduction,
  2. reduced values - instructions with the same opcodes, but different from the reduction opcode
  3. extra arguments - all other values, instructions from the different basic block rather than the root node, instructions with to many/less uses.

This scheme is not very efficient. It excludes some instructions and all
non-instruction values from the reductions (constants, proficient
gathers), to many possibly reduced values are marked as extra arguments.
Patch improves this process by introducing a bit extended analysis
stage. During this stage, we still try to select 3 classes of the
values: 1) reduction operations - same as before, 2) possibly reduced
values - all instructions from the current block/non-instructions, which
may build a vectorization tree, 3) extra arguments - instructions from
the different basic blocks. Additionally, an extra sorting of the
possibly reduced values occurs to build the scalar sequences which
highly likely will bed vectorized, e.g. loads are grouped by the
distance between them, constants are grouped together, cmp instructions
are sorted by their compare types and predicates, extractelement
instructions are sorted by the vector operand, etc. Also, these groups
are reordered by their length so the longest group is the first in the
list of the possibly reduced values.

The vectorization process tries to emit the reductions for all these
groups. These reductions, remaining non-vectorized possible reduced
values and extra arguments are then combined into the final expression
just like it was before.

Diff Detail

Event Timeline

ABataev created this revision.Thu, Nov 18, 9:29 AM
ABataev requested review of this revision.Thu, Nov 18, 9:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptThu, Nov 18, 9:29 AM
RKSimon edited the summary of this revision. (Show Details)Mon, Nov 22, 3:20 AM
RKSimon edited the summary of this revision. (Show Details)