[X86] combineX86ShuffleChain(): canonicalize mask elts picking from splats
authorRoman Lebedev <lebedev.ri@gmail.com>
Wed, 4 Aug 2021 13:46:29 +0000 (16:46 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Wed, 4 Aug 2021 13:55:04 +0000 (16:55 +0300)
commitf819e4c7d0f6efef3cc1042cc45582320bf6c0a2
treed284ff5a8c096ccc7817d73750b51f8d00f1749e
parent438f700b4d9e4fca1fd6fd932e53ac8ef1ec15ca
[X86] combineX86ShuffleChain(): canonicalize mask elts picking from splats

Given a shuffle mask, if it is picking from an input that is splat
given the current granularity of the shuffle, then adjust the mask
to pick from the same lane of the input as the mask element is in.
This may result in a shuffle being simplified into a blend.

I believe this is correct given that the splat detection matches the one
just above the new code,

My basic thought is that we might be able to get less regressions
by handling multiple insertions of the same value into a vector
if we form broadcasts+blend here, as opposed to D105390,
but i have not really thought this through,
and did not try implementing it yet.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D107009
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/avx.ll
llvm/test/CodeGen/X86/avx512-shuffles/partial_permute.ll
llvm/test/CodeGen/X86/pr15296.ll
llvm/test/CodeGen/X86/sse41.ll
llvm/test/CodeGen/X86/vector-shuffle-256-v32.ll