Skip to content

[SLP] Failure to vectorize interleaving of elements from two vector loads #44422

@LebedevRI

Description

@LebedevRI
Bugzilla Link 45077
Version trunk
OS Linux
CC @alexey-bataev,@dtemirbulatov,@fhahn,@RKSimon

Extended Description

#include

std::array<uint16_t, 16>
zz(const uint16_tconst row0, const uint16_tconst row1) {
std::array<uint16_t, 16> baseline;

// Preload the entire block from last two rows.
std::array<std::array<uint16_t, 16>, 2> prev;
for (int c = 0; c < 16; ++c)
  prev[1][c] = row0[c];
for (int c = 0; c < 16; ++c)
  prev[0][c] = row1[c];

// The differences are specified as compared to the pixels of the previous
// row for even pixels, or to pixels from two rows above for odd pixels.
for (int c = 0; c < 16; ++c)
  baseline[c] = prev[c & 1][c];

return baseline;

}

Currently results in rather scalar code, however i believe this should vectorize into something like

define <16 x i16> @​zz(<16 x i16>* %line0, <16 x i16>* %line1) {
%l0data = load <16 x i16>, <16 x i16>* %line0
%l1data = load <16 x i16>, <16 x i16>* %line1
%res = shufflevector <16 x i16> %l0data, <16 x i16> %l1data,
<16 x i32> <i32 0, i32 17, i32 2, i32 19, i32 4, i32 21, i32 6, i32 23, i32 8, i32 25, i32 10, i32 27, i32 12, i32 29, i32 14, i32 31>
ret <16 x i16> %res
}

https://godbolt.org/z/Pj7XkH

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions