[all-commits] [llvm/llvm-project] f42b93: [SLP] Pessimistically handle unknown vector entrie...

Maurice Heumann via All-commits all-commits at lists.llvm.org
Thu Dec 14 06:48:38 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f42b930af976e73fcf52e28d77ac6d94883bf950
      https://github.com/llvm/llvm-project/commit/f42b930af976e73fcf52e28d77ac6d94883bf950
  Author: Maurice Heumann <MauriceHeumann at gmail.com>
  Date:   2023-12-14 (Thu, 14 Dec 2023)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
    A llvm/test/Transforms/SLPVectorizer/X86/unknown-entries.ll

  Log Message:
  -----------
  [SLP] Pessimistically handle unknown vector entries in SLP vectorizer (#75438)

SLP Vectorizer can discard vector entries at unknown positions. This
example shows the behaviour:

https://godbolt.org/z/or43EM594

The following instruction inserts an element at an unknown position:

```
%2 = insertelement <3 x i64> poison, i64 %value, i64 %position
```

The position depends on an argument that is unknown at compile time.

After running SLP, one can see there is no more instruction present
referencing `%position`.

This happens as SLP parallelizes the two adds in the example. It then
needs to merge the original vector with the new vector.

Within `isUndefVector`, the SLP vectorizer constructs a bitmap
indicating which elements of the original vector are poison values. It
does this by walking the insertElement instructions.

If it encounters an insert with a non-constant position, it is ignored.
This will result in poison values to be used for all entries, where
there are no inserts with constant positions.

However, as the position is unknown, the element could be anywhere.
Therefore, I think it is only safe to assume none of the entries are
poison values and to simply take them all over when constructing the
shuffleVector instruction.

This fixes #75437




More information about the All-commits mailing list