From 87a5bf9ead1fc2cdbe918b5e1f4b6b09735f1c0c Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 7 Apr 2020 14:36:33 -0500 Subject: [PATCH] [LLVM] Use llvm::ElementCount with LLVM 11+ when creating vectors 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. --- src/target/llvm/codegen_llvm.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index 450ebbcd02b8..848047dbc1fe 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -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); }