Unverified Commit df8a6f3b by Krzysztof Parzyszek Committed by GitHub

[LLVM] Use llvm::ElementCount with LLVM 11+ when creating vectors (#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.
parent 36ce2e24
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment