Page MenuHomePhabricator

[WebAssembly] Use ISD::SPLAT_VECTOR for splats
Changes PlannedPublic

Authored by tlively on Fri, Jul 10, 12:27 AM.

Details

Reviewers
aheejin
dschuff
Summary

This patch legalizes ISD::SPLAT_VECTOR to enable the generic DAG
combines that create splat_vector nodes. This simplifies some ISel
patterns, although ISD::isBuildVectorAllOnes has to be extended to
recognize splat_vectors to keep the vnot pattern fragment working.

The AddedComplexity for splats is also removed so that we no longer
prefer constant splats over v128.const instructions. This is
consistent with the instruction preferences used in BUILD_VECTOR
lowering and reduces the instruction count in many tests.

There is a small regression in that insert_vector_elts into undef
vectors at constant indices that could previously have been turned
into swizzles can no longer be simplified that way because those nodes
are combined to splat_vector nodes instead of BUILD_VECTOR nodes. This
change includes a custom target combine meant to fix this, but
unfortunately the generic combine gets precedence over the custom
combine. Fixing this is left as future work, and the custom combine is
kept because it is still useful in the non-constant index case. See
@swizzle_one_i8x16 and @swizzle_one_var_i8x16 in simd-build-vector.ll
for details.

The motivation for this change is that follow-on patches will
introduce new combines that will greatly improve codegen for splatted
vector shift values but rely on splats having no undef lanes. Unlike a
splatting build_vector, a splat_vector node never has undef lanes.

Diff Detail

Event Timeline

tlively created this revision.Fri, Jul 10, 12:27 AM
tlively planned changes to this revision.Fri, Jul 10, 12:38 AM

This whole patch got a whole lot more complex than I thought it would be at first, so I'm going to split out some of the separately-useful parts and experiment with other ways of getting rid of the undef lanes in splat build_vectors.