Skip to content

[VectorCombine] foldShuffleOfShuffles - failure to fold shuffle(shuffle(x,y),undef) length changing masks #144656

@RKSimon

Description

@RKSimon
Collaborator
define <8 x float> @shuffle(<4 x float> %a0, <4 x float> %a1) {
  %x = shufflevector <4 x float> %a0, <4 x float> %a1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
  %y = shufflevector <8 x float> %x, <8 x float> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
  ret <8 x float> %y
}

foldShuffleOfShuffles currently fails to merge "permute of shuffle" patterns if the vector length changes

But it will happily fold:

define <4 x float> @shuffle2(<4 x float> %a0, <4 x float> %a1) {
  %x = shufflevector <4 x float> %a0, <4 x float> %a1, <4 x i32> <i32 0, i32 4, i32 5, i32 3>
  %y = shufflevector <4 x float> %x, <4 x float> poison, <4 x i32> <i32 0, i32 3, i32 1, i32 2>
  ret <4 x float> %y
}
->
define <4 x float> @shuffle2(<4 x float> %a0, <4 x float> %a1) {
  %y = shufflevector <4 x float> %a0, <4 x float> %a1, <4 x i32> <i32 0, i32 3, i32 4, i32 5>
  ret <4 x float> %y
}

Activity

self-assigned this
on Jun 18, 2025
added a commit that references this issue on Jun 18, 2025
ed15ee0
added a commit that references this issue on Jun 22, 2025
26390f2
added and removed
llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passes
on Jun 22, 2025
added a commit that references this issue on Jun 23, 2025
0485d54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @RKSimon@EugeneZelenko

    Issue actions

      [VectorCombine] foldShuffleOfShuffles - failure to fold shuffle(shuffle(x,y),undef) length changing masks · Issue #144656 · llvm/llvm-project