Skip to content

Commit

Permalink
[LLVM] Use llvm::ElementCount with LLVM 11+ when creating vectors (#5265
Browse files Browse the repository at this point in the history
)

LLVM 11 added support for scalable vectors, and now the number of
elements in a vector is represented by a llvm::ElementCount class,
not just a number.
  • Loading branch information
Krzysztof Parzyszek authored Apr 7, 2020
1 parent 36ce2e2 commit df8a6f3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/target/llvm/codegen_llvm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,12 @@ llvm::Value* CodeGenLLVM::CreateBroadcast(llvm::Value* value, int lanes) {
llvm::VectorType::get(value->getType(), lanes));
llvm::Constant* zero = ConstInt32(0);
value = builder_->CreateInsertElement(undef, value, zero);
#if TVM_LLVM_VERSION >= 110
llvm::Constant* mask =
llvm::ConstantVector::getSplat(llvm::ElementCount(lanes, /*Scalable=*/false), zero);
#else
llvm::Constant* mask = llvm::ConstantVector::getSplat(lanes, zero);
#endif
return builder_->CreateShuffleVector(value, undef, mask);
}

Expand Down

0 comments on commit df8a6f3

Please sign in to comment.