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

[VectorCombine] transform shuffle of binops with common operand #51520

Closed
rotateright opened this issue Oct 14, 2021 · 2 comments
Closed

[VectorCombine] transform shuffle of binops with common operand #51520

rotateright opened this issue Oct 14, 2021 · 2 comments
Labels
bugzilla Issues migrated from bugzilla

Comments

@rotateright
Copy link
Contributor

Bugzilla Link 52178
Resolution FIXED
Resolved on Oct 21, 2021 09:41
Version trunk
OS All
CC @RKSimon

Extended Description

Adapted/reduced from the regression test in https://reviews.llvm.org/D111800 (that example could have further shuffle combining which would eliminate a shuffle and almost definitely be a win):

define <3 x i3> @​src(<3 x i3> %x, <3 x i3> %y, <3 x i3> %z) {
%a1 = sub <3 x i3> %x, %y
%a2 = sub <3 x i3> %x, %z
%r = shufflevector <3 x i3> %a1, <3 x i3> %a2, <3 x i32> <i32 0, i32 5, i32 3>
ret <3 x i3> %r
}

define <3 x i3> @​tgt(<3 x i3> %x, <3 x i3> %y, <3 x i3> %z) {
%s1 = shufflevector <3 x i3> %x, <3 x i3> %x, <3 x i32> <i32 0, i32 5, i32 3>
%s2 = shufflevector <3 x i3> %y, <3 x i3> %z, <3 x i32> <i32 0, i32 5, i32 3>
%r2 = sub <3 x i3> %s1, %s2
ret <3 x i3> %r2
}

https://alive2.llvm.org/ce/z/d8zB4D

Note: the shuffle of '%x' can be reduced to a unary shuffle; I left the mask as-is to show that we're re-using the incoming shuffle mask.

As long as the shuffle is no more expensive than the binop, this should be a win and would potentially allow subsequent combines.

@rotateright
Copy link
Contributor Author

@rotateright
Copy link
Contributor Author

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

1 participant