Skip to content

[VectorCombine] foldInsExtVectorToShuffle can't handle length changing shuffles #120772

Closed
@RKSimon

Description

@RKSimon

The VectorCombine::foldInsExtVectorToShuffle fold insert (DstVec, (extract SrcVec, ExtIdx), InsIdx) --> shuffle (DstVec, SrcVec, Mask) is limited to cases where the DstVec/SrcVec are the same vector type, but it might still be cost beneficial to fold these for non matching shuffles assuming any shuffle narrowing/widening for SrcVec is cheap enough.

define <4 x double> @ins0_v4f64_ext1_v2f64(<4 x double> %a, <2 x double> %b) {
  %ext = extractelement <2 x double> %b, i32 1
  %ins = insertelement <4 x double> %a, double %ext, i32 0
  ret <4 x double> %ins
}
define <2 x double> @ins1_v2f64_ext1_v4f64(<2 x double> %a, <4 x double> %b) {
  %ext = extractelement <4 x double> %b, i32 1
  %ins = insertelement <2 x double> %a, double %ext, i32 1
  ret <2 x double> %ins
}

InstCombine will handle some 'easy' cases, but ideally we need VectorCombine to handle this more generally as a cost driven combine.

CC @ParkHanbum who handled something similar recently for #115209

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions