Skip to content

Commit

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

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 and dpankratz committed Apr 24, 2020
1 parent f7fc9a3 commit df87292
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 df87292

Please sign in to comment.