This is split out from D41062 to cover the code in LegalVectorTypes.cpp
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 22039 Build 22039: arc lint + arc unit
Event Timeline
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.
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.