Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x86] improve cost model for oversized shuffles #55170

Open
rotateright opened this issue Apr 28, 2022 · 4 comments
Open

[x86] improve cost model for oversized shuffles #55170

rotateright opened this issue Apr 28, 2022 · 4 comments

Comments

@rotateright
Copy link
Contributor

rotateright commented Apr 28, 2022

I was trying some examples with https://reviews.llvm.org/D123494 and noticed that AArch64 seems smarter about decomposing shuffle costs via mask:

define void @cross_talk(<8 x i32> %a, <8 x i32> %b) {
  %s = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 8, i32 0, i32 1, i32 2, i32 3, i32 8, i32 8, i32 8>
  ret void
}

If we don't care about element order, that can be turned into the much simpler (especially for a 128-bit vector target):

define void @identity_and_splat(<8 x i32> %a, <8 x i32> %b) {
  %s = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 8, i32 8, i32 8>
  ret void
}

That transform happens with AArch64, but that doesn't happen with x86 because:

% opt -mtriple=x86_64 -passes="print<cost-model>" -disable-output shufcost.ll 
Printing analysis 'Cost Model Analysis' for function 'cross_talk':
Cost Model: Found an estimated cost of 12 for instruction:   %s = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 8, i32 0, i32 1, i32 2, i32 3, i32 8, i32 8, i32 8>

Printing analysis 'Cost Model Analysis' for function 'identity_and_splat':
Cost Model: Found an estimated cost of 12 for instruction:   %s = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 8, i32 8, i32 8>
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 28, 2022

@llvm/issue-subscribers-backend-x86

@fhahn
Copy link
Contributor

fhahn commented Apr 28, 2022

Looks like GitHub-actions removes any user provided labels when it adds the new-issue label :(

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 28, 2022

@llvm/issue-subscribers-backend-x86

@rotateright
Copy link
Contributor Author

https://reviews.llvm.org/D100486 seems like it would help. It was committed, but it is currently reverted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants