This is an archive of the discontinued LLVM Phabricator instance.

[X86] Support v2i32 gather/scatter indices with -x86-experimental-vector-widening-legalization
ClosedPublic

Authored by craig.topper on Aug 27 2018, 9:49 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Aug 27 2018, 9:49 PM

Widening everything when the index needs to be widened is awkward. It's not clear what's supposed to happen if widening the index to make it legal makes the value illegal. The way it's implemented, you'll end up in an infinite loop of splitting and widening. (Not sure the infinite loop can happen for legal gather/scatter operations on x86, but it could show up in other cases.) And for test_scatter_v2i32_index, we don't generate the expected instruction in either mode; it should be vscatterdpd %xmm0, (%rdi,%xmm1,8) {%k1}.

Can we implement some rule that allows the index of an MGATHER to have more elements than the data, and the upper elements are ignored? Sort of like an implicit SIGN_EXTEND_VECTOR_INREG.

Take Eli's suggestion and only widen the index. This fixes the scatter/gather index only widening cases to use the better instruction. The default 'promote' case is still promoting to a v2i64 index type since that's what type legalization will naturally do.

I've also added KNL and AVX2 command lines so we can see those too. On KNL we prefer to use the 512-bit gather/scatter with a vXi1 mask. For AVX2 we don't have scatter and the gather mask is a vector register.

I think I accidentally merged by commits on my tree and picked up some extra files.

efriedma accepted this revision.Aug 28 2018, 5:37 PM

LGTM.

Please update ISDOpcodes.h at some point with more info on what exactly the operands to MGATHER/MSCATTER mean; I had to dig a bit to figure it out, and it's only getting more complicated with the new legalization rules.

This revision is now accepted and ready to land.Aug 28 2018, 5:37 PM
This revision was automatically updated to reflect the committed changes.