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

Fix #8455 (in combination with #8457) #8456

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4954,11 +4954,18 @@ Value *CodeGen_LLVM::concat_vectors(const vector<Value *> &v) {

Value *CodeGen_LLVM::shuffle_vectors(Value *a, Value *b,
const std::vector<int> &indices) {
internal_assert(a->getType() == b->getType());
if (isa<llvm::ScalableVectorType>(a->getType())) {
a = scalable_to_fixed_vector_type(a);
}
if (isa<llvm::ScalableVectorType>(b->getType())) {
b = scalable_to_fixed_vector_type(b);
}
if (!a->getType()->isVectorTy()) {
a = create_broadcast(a, 1);
b = create_broadcast(b, 1);
}
// Check for type identity *after* normalizing to fixed vectors
internal_assert(a->getType() == b->getType());
vector<Constant *> llvm_indices(indices.size());
for (size_t i = 0; i < llvm_indices.size(); i++) {
if (indices[i] >= 0) {
Expand All @@ -4970,12 +4977,6 @@ Value *CodeGen_LLVM::shuffle_vectors(Value *a, Value *b,
llvm_indices[i] = PoisonValue::get(i32_t);
}
}
if (isa<llvm::ScalableVectorType>(a->getType())) {
a = scalable_to_fixed_vector_type(a);
}
if (isa<llvm::ScalableVectorType>(b->getType())) {
b = scalable_to_fixed_vector_type(b);
}
return builder->CreateShuffleVector(a, b, ConstantVector::get(llvm_indices));
}

Expand Down
4 changes: 3 additions & 1 deletion src/CodeGen_LLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ class CodeGen_LLVM : public IRVisitor {
/** Concatenate a bunch of llvm vectors. Must be of the same type. */
virtual llvm::Value *concat_vectors(const std::vector<llvm::Value *> &);

/** Create an LLVM shuffle vectors instruction. */
/** Create an LLVM shuffle vectors instruction. Takes a combination of
* fixed or scalable vectors as input, so long as the effective lengths match,
* but always returns a fixed vector. */
virtual llvm::Value *shuffle_vectors(llvm::Value *a, llvm::Value *b,
const std::vector<int> &indices);
/** Shorthand for shuffling a single vector. */
Expand Down
Loading