Undefined indices in shuffles can be used when not all lanes of the output vector will be used. This happens for example in the expansion of vector reduce operations. Regardless, undefs are legal as lane indices in IR and should be supported.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Could you give an example of what kind of programs would generate undefs in the IR and why we need this? And also I guess it's good to include that in the CL and the commit description.
lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | ||
---|---|---|
1032 ↗ | (On Diff #169139) | Why -1? Is it how undef is represented? |
lib/Target/WebAssembly/WebAssemblyInstrSIMD.td | ||
194 ↗ | (On Diff #169139) | Are these unnecessary sequence of masking by and also removed in non-undef cases? |
202 ↗ | (On Diff #169139) | Here the same. Are these sext_inreg also removed in non-undef cases? |
232 ↗ | (On Diff #169139) | Move this pattern to extract_lane category above |
test/CodeGen/WebAssembly/simd.ll | ||
133 ↗ | (On Diff #169139) | i32 undef? For all other replace_undef_ functions too. |
lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | ||
---|---|---|
1032 ↗ | (On Diff #169139) | I think MaskVal sounds confusing. It sounds like it is a mask value (such as 0xff). Can we change it to something else, like, just Val or something? |
lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | ||
---|---|---|
1032 ↗ | (On Diff #169139) | ByteIndex seemed like a nice descriptive name. |
1032 ↗ | (On Diff #169139) | Yes, that seems to be how undef is represented. |
lib/Target/WebAssembly/WebAssemblyInstrSIMD.td | ||
194 ↗ | (On Diff #169139) | Yes, see multiclass ExtractLaneExtended, which uses the corresponding patterns in multiclass ExtractPat. |
202 ↗ | (On Diff #169139) | Yes, same as above. |
LGTM with a nit.
lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | ||
---|---|---|
1032 ↗ | (On Diff #169139) | Then one-line comment stating that here -1 means undef would be helpful I think. |