[all-commits] [llvm/llvm-project] 7a9876: [NFC] Move CombinationGenerator from Exegesis to ADT

Roman Lebedev via All-commits all-commits at lists.llvm.org
Fri Nov 5 06:54:09 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7a98761d74dba56bbbb112fac2a04c89d3776c7c
      https://github.com/llvm/llvm-project/commit/7a98761d74dba56bbbb112fac2a04c89d3776c7c
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2021-11-05 (Fri, 05 Nov 2021)

  Changed paths:
    A llvm/include/llvm/ADT/CombinationGenerator.h
    M llvm/tools/llvm-exegesis/lib/SnippetGenerator.h
    M llvm/unittests/ADT/CMakeLists.txt
    A llvm/unittests/ADT/CombinationGeneratorTest.cpp
    M llvm/unittests/tools/llvm-exegesis/CMakeLists.txt
    R llvm/unittests/tools/llvm-exegesis/SnippetGeneratorTest.cpp

  Log Message:
  -----------
  [NFC] Move CombinationGenerator from Exegesis to ADT

Reviewed By: courbet

Differential Revision: https://reviews.llvm.org/D113213


  Commit: 01d8759ac9ad73cf9235f4f85abdfaa26abaaef5
      https://github.com/llvm/llvm-project/commit/01d8759ac9ad73cf9235f4f85abdfaa26abaaef5
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2021-11-05 (Fri, 05 Nov 2021)

  Changed paths:
    M llvm/include/llvm/IR/Instructions.h
    M llvm/lib/IR/Instructions.cpp
    M llvm/unittests/IR/InstructionsTest.cpp

  Log Message:
  -----------
  [IR][ShuffleVector] Introduce `isReplicationMask()` matcher

Avid readers of this saga may recall from previous installments,
that replication mask replicates (lol) each of the `VF` elements
in a vector `ReplicationFactor` times. For example, the mask for
`ReplicationFactor=3` and `VF=4` is: `<0,0,0,1,1,1,2,2,2,3,3,3>`.
More importantly, replication mask is used by LoopVectorizer
when using masked interleaved memory operations.

As discussed in previous installments, while it is used by LV,
and we **seem** to support masked interleaved memory operations on X86,
it's support in cost model leaves a lot to be desired:
until basically yesterday even for AVX512 we had no cost model for it.

As it has been witnessed in the recent
AVX2 `X86TTIImpl::getInterleavedMemoryOpCost()`
costmodel patches, while it is hard-enough to query the cost
of a particular assembly sequence [from llvm-mca],
afterwards the check lines LV costmodel tests must be updated manually.
This is, at the very least, boring.

Okay, now we have decent costmodel coverage for interleaving shuffles,
but now basically the same mind-killing sequence has to be performed
for replication mask. I think we can improve at least the second half
of the problem, by teaching
the `TargetTransformInfoImplCRTPBase::getUserCost()` to recognize
`Instruction::ShuffleVector` that are repetition masks,
adding exhaustive test coverage
using `-cost-model -analyze` + `utils/update_analyze_test_checks.py`

This way we can have good exhaustive coverage for cost model,
and only basic coverage for the LV costmodel.

This patch adds precise undef-aware `isReplicationMask()`,
with exhaustive test coverage.
* `InstructionsTest.ShuffleMaskIsReplicationMask` shows that
   it correctly detects all the known masks.
* `InstructionsTest.ShuffleMaskIsReplicationMask_undef`
  shows that replacing some mask elements in a known replication mask
  still allows us to recognize it as a replication mask.
  Note, with enough undef elts, we may detect a different tuple.
* `InstructionsTest.ShuffleMaskIsReplicationMask_Exhaustive_Correctness`
  shows that if we detected the replication mask with given params,
  then if we actually generate a true replication mask with said params,
  it matches element-wise ignoring undef mask elements.

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D113214


Compare: https://github.com/llvm/llvm-project/compare/657a1dcd0dca...01d8759ac9ad


More information about the All-commits mailing list