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

Single-operand vector shuffling #667

Open
seven-mile opened this issue Jun 7, 2024 · 2 comments
Open

Single-operand vector shuffling #667

seven-mile opened this issue Jun 7, 2024 · 2 comments
Labels
good first issue Good for newcomers

Comments

@seven-mile
Copy link
Collaborator

seven-mile commented Jun 7, 2024

Mentioned in #613 .

Some times we need to do single-operand vector shuffling. LLVM uses the form shuffle(v, undef / poison, mask), while CIR currently uses shuffle(v, v, mask) as we don't have equivalent for undef / poison. This causes different emissions of IR. Not very critical problem though.

A direct approach will be add one equivalent. In #628 Bruno mentioned that

Btw, it's possible we might need an undef attribute someday, but up to now we should be good without one!

The other approaches include unifying the two forms in CIR with canonicalization (or at least something similar). Open for other ideas.

@bcardosolopes
Copy link
Member

Alternatively, we could make the second operand to be optional, and teach verifier how to look into those if necessary

@ghehg
Copy link
Collaborator

ghehg commented Oct 10, 2024

As to VecShuffleOp, it's just just implementation
Value *CreateShuffleVector(Value *V1, Value *V2, Value *Mask,
const Twine &Name = "")
in LLVM.
Of course as you mention, LLVM has the following wrapper that is used more often.

/// Create a unary shuffle. The second vector operand of the IR instruction
/// is poison.
Value *CreateShuffleVector(Value *V, ArrayRef Mask,
const Twine &Name = "")

Yeah, if in future, we found majority cases for VecShuffleOp for its second Arg is poision, then we be we should consider
this unary shuffle op.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants