From d70e1e15bb7cbcbe235d58d8d3b14fc43bd4b1a8 Mon Sep 17 00:00:00 2001 From: Jan Palus Date: Tue, 9 Nov 2021 01:19:58 +0100 Subject: [PATCH] up to 1.0.8744 --- intel-graphics-compiler.spec | 17 +- llvm12.patch | 2397 ---------------------------------- 2 files changed, 10 insertions(+), 2404 deletions(-) delete mode 100644 llvm12.patch diff --git a/intel-graphics-compiler.spec b/intel-graphics-compiler.spec index 07beb1d..e39bf2c 100644 --- a/intel-graphics-compiler.spec +++ b/intel-graphics-compiler.spec @@ -1,22 +1,24 @@ # requires the OpenCL patches -%define llvm_version 12.0.0 +%define llvm_version 13.0.0 -%define opencl_clang_version 12.0.0 +%define opencl_clang_version 13.0.0 Summary: The Intel Graphics Compiler for OpenCL Name: intel-graphics-compiler -Version: 1.0.7423 +Version: 1.0.8744 Release: 1 License: MIT Group: Libraries Source0: https://github.com/intel/intel-graphics-compiler/archive/igc-%{version}/igc-%{version}.tar.gz -# Source0-md5: a24f432bd43fe1f5ff04a2fa47961ad1 +# Source0-md5: 924a22c69af76c9679a6fa799d555bd2 +Source1: https://github.com/llvm/llvm-project/raw/llvmorg-%{llvm_version}/libunwind/include/mach-o/compact_unwind_encoding.h +# Source1-md5: de130d4e72f9e1c750ce09deee4aad4e Patch0: pkgconfig.patch Patch1: cxx_flags.patch Patch2: missing-header.patch -Patch3: llvm12.patch URL: https://github.com/intel/intel-graphics-compiler/ +BuildRequires: lld-devel >= %{llvm_version} BuildRequires: llvm-devel >= %{llvm_version} BuildRequires: opencl-clang-devel >= %{opencl_clang_version} BuildRequires: cmake >= 3.2.0 @@ -55,9 +57,10 @@ Pliki nagłówkowe biblioteki %{name}. %patch0 -p1 %patch1 -p1 %patch2 -p1 -%patch3 -p1 -%{__sed} -i -e 's/-Werror/-Werror -Wno-error=deprecated-declarations/' IGC/CMakeLists.txt +install -D %{SOURCE1} build/IGC/llvm-deps/src/libunwind/include/mach-o/compact_unwind_encoding.h + +%{__sed} -i -e 's/-Werror/-Werror -Wno-error=deprecated-declarations -Wno-error=nonnull/' IGC/CMakeLists.txt %build install -d build diff --git a/llvm12.patch b/llvm12.patch deleted file mode 100644 index 67627b0..0000000 --- a/llvm12.patch +++ /dev/null @@ -1,2397 +0,0 @@ -From 1c28c742daac3e2d2a3188716d913dd515f18acb Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= - -Date: Mon, 26 Apr 2021 11:10:59 +0000 -Subject: [PATCH] Fix build with LLVM 12 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Removed TargetLibraryInfo.h include from AddressSpaceAliasAnalysis.cpp -as this was causing treat-warning-as-error buildbreak, -Added casts to fix warnings, -Replaced ConstantPropagation and IPConstantPropagation passes with -IPSCCP passes, -reasoning here: -https://lists.llvm.org/pipermail/llvm-dev/2020-July/143788.html - -Original pull-request: -intel/intel-graphics-compiler#171 - -Signed-off-by: Zoltán Böszörményi zboszor@gmail.com -Co-authored-by: Pawel Szymichowski pawel.szymichowski@intel.com - -Co-authored-by: Zoltán Böszörményi zboszor@pr.hu ---- - .../LegalizeFunctionSignatures.cpp | 2 +- - IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp | 22 ++++++------ - IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp | 4 +-- - IGC/Compiler/CISACodeGen/AdvMemOpt.cpp | 3 +- - IGC/Compiler/CISACodeGen/CShader.cpp | 12 +++---- - .../CISACodeGen/ConstantCoalescing.cpp | 14 ++++---- - IGC/Compiler/CISACodeGen/DeSSA.cpp | 3 +- - IGC/Compiler/CISACodeGen/EmitVISAPass.cpp | 35 ++++++++++--------- - IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp | 4 +-- - IGC/Compiler/CISACodeGen/GenIRLowering.cpp | 4 +-- - .../CISACodeGen/GenSimplification.cpp | 5 +-- - .../CISACodeGen/GeometryShaderLowering.cpp | 3 +- - IGC/Compiler/CISACodeGen/LdShrink.cpp | 10 ++++-- - .../CISACodeGen/LowerGEPForPrivMem.cpp | 8 ++--- - IGC/Compiler/CISACodeGen/MemOpt.cpp | 8 ++--- - IGC/Compiler/CISACodeGen/MemOpt2.cpp | 5 +-- - .../CISACodeGen/OpenCLKernelCodeGen.cpp | 2 +- - IGC/Compiler/CISACodeGen/PatternMatchPass.cpp | 4 +-- - IGC/Compiler/CISACodeGen/PushAnalysis.cpp | 4 +-- - .../CISACodeGen/RegisterEstimator.cpp | 3 +- - .../CISACodeGen/RegisterPressureEstimate.hpp | 3 +- - IGC/Compiler/CISACodeGen/SLMConstProp.cpp | 3 +- - .../CISACodeGen/ScalarizerCodeGen.cpp | 4 +-- - IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp | 10 ++++++ - .../CISACodeGen/Simd32Profitability.cpp | 10 +++--- - IGC/Compiler/CISACodeGen/SimplifyConstant.cpp | 12 +++---- - IGC/Compiler/CISACodeGen/TypeDemote.cpp | 3 +- - .../CISACodeGen/VariableReuseAnalysis.cpp | 5 +-- - .../CISACodeGen/VariableReuseAnalysis.hpp | 3 +- - IGC/Compiler/CISACodeGen/VectorPreProcess.cpp | 24 ++++++------- - IGC/Compiler/CISACodeGen/VectorProcess.cpp | 4 +-- - IGC/Compiler/CISACodeGen/helper.cpp | 10 +++--- - IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp | 10 +++--- - IGC/Compiler/CustomSafeOptPass.cpp | 26 +++++++------- - IGC/Compiler/DebugInfo/ScalarVISAModule.cpp | 3 +- - IGC/Compiler/GenTTI.cpp | 3 +- - IGC/Compiler/GenUpdateCB.cpp | 3 +- - IGC/Compiler/HandleFRemInstructions.cpp | 3 +- - IGC/Compiler/HandleLoadStoreInstructions.cpp | 4 +-- - IGC/Compiler/LegalizationPass.cpp | 28 +++++++-------- - IGC/Compiler/Legalizer/InstPromoter.cpp | 5 +-- - IGC/Compiler/Legalizer/InstScalarizer.cpp | 6 ++-- - .../Legalizer/PeepholeTypeLegalizer.cpp | 6 ++-- - IGC/Compiler/Legalizer/TypeLegalizer.cpp | 3 +- - IGC/Compiler/Legalizer/TypeLegalizer.h | 3 +- - IGC/Compiler/LowPrecisionOptPass.cpp | 2 +- - .../AggregateArguments/AggregateArguments.cpp | 3 +- - .../CorrectlyRoundedDivSqrt.cpp | 3 +- - .../DeviceEnqueueFuncs/TransformBlocks.cpp | 4 +-- - .../Optimizer/OpenCLPasses/KernelArgs.cpp | 3 +- - .../OpenCLPrintf/OpenCLPrintfResolution.cpp | 4 +-- - .../PrivateMemory/PrivateMemoryResolution.cpp | 9 +++-- - .../ReplaceUnsupportedIntrinsics.cpp | 4 +-- - .../OpenCLPasses/WIFuncs/WIFuncResolution.cpp | 2 +- - .../Optimizer/PreCompiledFuncImport.cpp | 4 +-- - IGC/Compiler/Optimizer/Scalarizer.cpp | 32 ++++++++--------- - IGC/Compiler/Optimizer/ValueTracker.cpp | 2 +- - IGC/Compiler/VerificationPass.cpp | 2 +- - IGC/DebugInfo/DebugInfoUtils.hpp | 2 +- - IGC/DebugInfo/DwarfDebug.cpp | 4 +-- - IGC/GenISAIntrinsics/GenIntrinsics.cpp | 6 ++-- - .../BuiltinsFrontendDefinitions.hpp | 2 +- - .../include/llvmWrapper/IR/DerivedTypes.h | 10 ++++++ - .../include/llvmWrapper/Support/TypeSize.h | 6 +++- - .../include/llvmWrapper/Transforms/Scalar.h | 4 +-- - .../llvmWrapper/Transforms/Utils/LoopUtils.h | 8 +++++ - IGC/common/igc_resourceDimTypes.h | 5 +++ - 67 files changed, 269 insertions(+), 201 deletions(-) - -diff --git a/IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp b/IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp -index 767f6b462b..fe0d578b9e 100644 ---- a/IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp -+++ b/IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp -@@ -140,7 +140,7 @@ inline Type* LegalizedIntVectorType(Module& M, const Type* const oldTy) - else if (size <= 64) newSize = 64; - else IGC_ASSERT_MESSAGE(0, "Currently don't support upscaling int sizes > 64 bits"); - -- return IGCLLVM::FixedVectorType::get(IntegerType::get(M.getContext(), newSize), (unsigned)cast(oldTy)->getNumElements()); -+ return IGCLLVM::FixedVectorType::get(IntegerType::get(M.getContext(), newSize), (unsigned)cast(oldTy)->getNumElements()); - } - - void LegalizeFunctionSignatures::FixFunctionSignatures() -diff --git a/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp b/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp -index fbdb12333b..c334ee3c50 100644 ---- a/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp -+++ b/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp -@@ -1577,7 +1577,7 @@ void SPIRVToLLVMDbgTran::transDbgInfo(SPIRVValue *SV, Value *V) { - Line->getColumn(), scope, iat); - - if(scope && !isa(scope)) -- I->setDebugLoc(DebugLoc::get(Line->getLine(), Line->getColumn(), -+ I->setDebugLoc(DILocation::get(scope->getContext(), Line->getLine(), Line->getColumn(), - scope, iat)); - } - } -@@ -1929,7 +1929,7 @@ SPIRVToLLVM::transType(SPIRVType *T) { - auto name = isSubgroupAvcINTELTypeOpCode(OC) ? - OCLSubgroupINTELTypeOpCodeMap::rmap(OC) : - BuiltinOpaqueGenericTypeOpCodeMap::rmap(OC); -- auto *pST = M->getTypeByName(name); -+ auto *pST = IGCLLVM::getTypeByName(M, name); - pST = pST ? pST : StructType::create(*Context, name); - - return mapType(T, PointerType::get(pST, getOCLOpaqueTypeAddrSpace(OC))); -@@ -2407,7 +2407,7 @@ Value *SPIRVToLLVM::promoteBool(Value *pVal, BasicBlock *BB) - - auto *PromoType = isa(pVal->getType()) ? - cast(IGCLLVM::FixedVectorType::get(Type::getInt8Ty(pVal->getContext()), -- (unsigned)cast(pVal->getType())->getNumElements())) : -+ (unsigned)cast(pVal->getType())->getNumElements())) : - Type::getInt8Ty(pVal->getContext()); - - if (auto *C = dyn_cast(pVal)) -@@ -2449,7 +2449,7 @@ Value *SPIRVToLLVM::truncBool(Value *pVal, BasicBlock *BB) - - auto *TruncType = isa(pVal->getType()) ? - cast(IGCLLVM::FixedVectorType::get(Type::getInt1Ty(pVal->getContext()), -- (unsigned)cast(pVal->getType())->getNumElements())) : -+ (unsigned)cast(pVal->getType())->getNumElements())) : - Type::getInt1Ty(pVal->getContext()); - - if (auto *C = dyn_cast(pVal)) -@@ -2495,7 +2495,7 @@ Type *SPIRVToLLVM::truncBoolType(SPIRVType *SPVType, Type *LLType) - - return isa(LLType) ? - cast(IGCLLVM::FixedVectorType::get(Type::getInt1Ty(LLType->getContext()), -- (unsigned)cast(LLType)->getNumElements())) : -+ (unsigned)cast(LLType)->getNumElements())) : - Type::getInt1Ty(LLType->getContext()); - } - -@@ -2652,7 +2652,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F, - { - if(CV[i]->getType()->isVectorTy()) - { -- for(uint32_t j = 0; j < cast(CV[i]->getType())->getNumElements(); j++) -+ for(uint32_t j = 0; j < cast(CV[i]->getType())->getNumElements(); j++) - { - Value *v = ExtractElementInst::Create( CV[i],ConstantInt::get( *Context,APInt( 32,j ) ),BCC->getName(),BB ); - elm1 = CreateCompositeConstruct( elm1,v,pos++ ); -@@ -3346,7 +3346,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F, - auto Vector = transValue(BI->getOperand(0), F, BB); - auto Scalar = transValue(BI->getOperand(1), F, BB); - -- auto VecType = cast(Vector->getType()); -+ auto VecType = cast(Vector->getType()); - auto Undef = UndefValue::get(VecType); - - auto ScalarVec = InsertElementInst::Create(Undef, Scalar, -@@ -3371,7 +3371,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F, - a->getType()->getScalarSizeInBits() - 1); - auto *ShiftOp = isa(a->getType()) ? - ConstantVector::getSplat( -- IGCLLVM::getElementCount((unsigned)cast(a->getType())->getNumElements()), ShiftAmt) : -+ IGCLLVM::getElementCount((unsigned)cast(a->getType())->getNumElements()), ShiftAmt) : - ShiftAmt; - - // OCL C: -@@ -3715,15 +3715,15 @@ SPIRVToLLVM::transSPIRVBuiltinFromInst(SPIRVInstruction *BI, BasicBlock *BB) { - "", - BB); - } -- else if (cast(coordType)->getNumElements() != 4) -+ else if (cast(coordType)->getNumElements() != 4) - { - Value *undef = UndefValue::get(coordType); - - SmallVector shuffleIdx; -- for (unsigned i = 0; i < cast(coordType)->getNumElements(); i++) -+ for (unsigned i = 0; i < cast(coordType)->getNumElements(); i++) - shuffleIdx.push_back(ConstantInt::get(Type::getInt32Ty(*Context), i)); - -- for (uint64_t i = (unsigned)cast(coordType)->getNumElements(); i < 4; i++) -+ for (uint64_t i = (unsigned)cast(coordType)->getNumElements(); i < 4; i++) - shuffleIdx.push_back(ConstantInt::get(Type::getInt32Ty(*Context), 0)); - - imageCoordinateWiden = new ShuffleVectorInst( -diff --git a/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp b/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp -index 57821556d3..f4f0dee5af 100644 ---- a/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp -+++ b/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp -@@ -93,7 +93,7 @@ saveLLVMModule(Module *M, const std::string &OutputFile) { - PointerType* - getOrCreateOpaquePtrType(Module *M, const std::string &Name, - unsigned AddrSpace) { -- auto OpaqueType = M->getTypeByName(Name); -+ auto OpaqueType = IGCLLVM::getTypeByName(M, Name); - if (!OpaqueType) - OpaqueType = StructType::create(M->getContext(), Name); - return PointerType::get(OpaqueType, AddrSpace); -@@ -159,7 +159,7 @@ std::string recursive_mangle(const Type* pType) - return "i" + utostr(pType->getIntegerBitWidth()); - case IGCLLVM::VectorTyID: - { -- unsigned vecLen = (unsigned)cast(pType)->getNumElements(); -+ unsigned vecLen = (unsigned)cast(pType)->getNumElements(); - Type* pEltType = cast(pType)->getElementType(); - return "v" + utostr(vecLen) + recursive_mangle(pEltType); - } -diff --git a/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp b/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp -index 81acc6ce6a..a612a4739a 100644 ---- a/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp -+++ b/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp -@@ -33,6 +33,7 @@ IN THE SOFTWARE. - #include - #include - #include -+#include "llvmWrapper/Transforms/Utils/LoopUtils.h" - #include "common/LLVMWarningsPop.hpp" - #include "GenISAIntrinsics/GenIntrinsics.h" - #include "Compiler/CISACodeGen/ShaderCodeGen.hpp" -@@ -134,7 +135,7 @@ bool AdvMemOpt::runOnFunction(Function& F) { - for (auto I = LI->begin(), E = LI->end(); I != E; ++I) - for (auto DFI = df_begin(*I), DFE = df_end(*I); DFI != DFE; ++DFI) { - Loop* L = *DFI; -- if (L->empty()) -+ if (IGCLLVM::isInnermost(L)) - InnermostLoops.push_back(L); - } - -diff --git a/IGC/Compiler/CISACodeGen/CShader.cpp b/IGC/Compiler/CISACodeGen/CShader.cpp -index 86b7bfe663..e55a36ef9f 100644 ---- a/IGC/Compiler/CISACodeGen/CShader.cpp -+++ b/IGC/Compiler/CISACodeGen/CShader.cpp -@@ -434,7 +434,7 @@ void CShader::CreateAliasVars() - continue; - - Type* Ty = V->getType(); -- VectorType* VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Ty); - Type* BTy = VTy ? VTy->getElementType() : Ty; - int nelts = (VTy ? (int)VTy->getNumElements() : 1); - -@@ -984,7 +984,7 @@ bool CShader::InsideDivergentCF(llvm::Instruction* inst) - uint CShader::GetNbVectorElementAndMask(llvm::Value* val, uint32_t& mask) - { - llvm::Type* type = val->getType(); -- uint nbElement = int_cast(cast(type)->getNumElements()); -+ uint nbElement = int_cast(cast(type)->getNumElements()); - mask = 0; - // we don't process vector bigger than 31 elements as the mask has only 32bits - // If we want to support longer vectors we need to extend the mask size -@@ -1189,7 +1189,7 @@ uint32_t CShader::GetExtractMask(llvm::Value* vecVal) - { - return it->second; - } -- const unsigned int numChannels = vecVal->getType()->isVectorTy() ? (unsigned)cast(vecVal->getType())->getNumElements() : 1; -+ const unsigned int numChannels = vecVal->getType()->isVectorTy() ? (unsigned)cast(vecVal->getType())->getNumElements() : 1; - IGC_ASSERT_MESSAGE(numChannels <= 32, "Mask has 32 bits maximally!"); - return (1ULL << numChannels) - 1; - } -@@ -1197,7 +1197,7 @@ uint32_t CShader::GetExtractMask(llvm::Value* vecVal) - uint16_t CShader::AdjustExtractIndex(llvm::Value* vecVal, uint16_t index) - { - uint16_t result = index; -- if (cast(vecVal->getType())->getNumElements() < 32) -+ if (cast(vecVal->getType())->getNumElements() < 32) - { - uint32_t mask = GetExtractMask(vecVal); - for (uint i = 0; i < index; ++i) -@@ -1614,7 +1614,7 @@ auto sizeToSIMDMode = [](uint32_t size) - - CVariable* CShader::GetConstant(llvm::Constant* C, CVariable* dstVar) - { -- llvm::VectorType* VTy = llvm::dyn_cast(C->getType()); -+ IGCLLVM::FixedVectorType* VTy = llvm::dyn_cast(C->getType()); - if (C && VTy) - { // Vector constant - llvm::Type* eTy = VTy->getElementType(); -@@ -1839,7 +1839,7 @@ uint32_t CShader::GetNumElts(llvm::Type* type, bool isUniform) - { - IGC_ASSERT(type->getContainedType(0)->isIntegerTy() || type->getContainedType(0)->isFloatingPointTy()); - -- auto VT = cast(type); -+ auto VT = cast(type); - numElts *= (uint16_t)VT->getNumElements(); - } - return numElts; -diff --git a/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp b/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp -index 9a7b61834e..a9b75bc2f5 100644 ---- a/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp -+++ b/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp -@@ -224,7 +224,7 @@ static void checkInsertExtractMatch(InsertElementInst* insertInst, Value* base, - - static bool canReplaceInsert(InsertElementInst* insertElt) - { -- VectorType* VTy = cast(insertElt->getOperand(0)->getType()); -+ IGCLLVM::FixedVectorType* VTy = cast(insertElt->getOperand(0)->getType()); - ConstantInt* index = dyn_cast(insertElt->getOperand(2)); - if (!index || index->getZExtValue() != VTy->getNumElements() - 1) - { -@@ -312,7 +312,7 @@ void ConstantCoalescing::VectorizePrep(llvm::BasicBlock* bb) - { - if (load->getType()->isVectorTy() && wiAns->isUniform(load)) - { -- srcNElts = (uint32_t)cast(load->getType())->getNumElements(); -+ srcNElts = (uint32_t)cast(load->getType())->getNumElements(); - DenseMap extractElementMap; - - for (auto iter = load->user_begin(); iter != load->user_end(); iter++) -@@ -396,7 +396,7 @@ bool ConstantCoalescing::isProfitableLoad( - (isa(I) && wiAns->isUniform(I)) ? - 16 : 4; - -- if (cast(LoadTy)->getNumElements() > MaxVectorInput) -+ if (cast(LoadTy)->getNumElements() > MaxVectorInput) - return false; - - MaxEltPlus = CheckVectorElementUses(I); -@@ -1843,7 +1843,7 @@ void ConstantCoalescing::AdjustChunk(BufChunk* cov_chunk, uint start_adj, uint s - WIAnalysis::WIDependancy loadDep = wiAns->whichDepend(cov_chunk->chunkIO); - irBuilder->SetInsertPoint(cov_chunk->chunkIO->getNextNode()); - Value* vec = UndefValue::get(originalType); -- for (unsigned i = 0; i < cast(originalType)->getNumElements(); i++) -+ for (unsigned i = 0; i < cast(originalType)->getNumElements(); i++) - { - Value* channel = irBuilder->CreateExtractElement( - cov_chunk->chunkIO, irBuilder->getInt32(i + start_adj)); -@@ -1907,7 +1907,7 @@ void ConstantCoalescing::MoveExtracts(BufChunk* cov_chunk, Instruction* load, ui - irBuilder->SetInsertPoint(load->getNextNode()); - Type* vecType = load->getType(); - Value* vec = UndefValue::get(vecType); -- for (unsigned i = 0; i < cast(vecType)->getNumElements(); i++) -+ for (unsigned i = 0; i < cast(vecType)->getNumElements(); i++) - { - Value* channel = irBuilder->CreateExtractElement( - cov_chunk->chunkIO, irBuilder->getInt32(i + start_adj)); -@@ -1971,7 +1971,7 @@ void ConstantCoalescing::EnlargeChunk(BufChunk* cov_chunk, uint size_adj) - WIAnalysis::WIDependancy loadDep = wiAns->whichDepend(cov_chunk->chunkIO); - irBuilder->SetInsertPoint(cov_chunk->chunkIO->getNextNode()); - Value* vec = UndefValue::get(originalType); -- for (unsigned i = 0; i < cast(originalType)->getNumElements(); i++) -+ for (unsigned i = 0; i < cast(originalType)->getNumElements(); i++) - { - Value* channel = irBuilder->CreateExtractElement( - cov_chunk->chunkIO, irBuilder->getInt32(i)); -@@ -2408,7 +2408,7 @@ void ConstantCoalescing::ReplaceLoadWithSamplerLoad( - if (dstTy->isVectorTy()) - { - result = UndefValue::get(dstTy); -- for (uint i = 0; i < cast(dstTy)->getNumElements(); i++) -+ for (uint i = 0; i < cast(dstTy)->getNumElements(); i++) - { - Value* tmpData = ExtractFromSamplerData(cast(dstTy)->getElementType(), i); - result = irBuilder->CreateInsertElement(result, tmpData, irBuilder->getInt32(i)); -diff --git a/IGC/Compiler/CISACodeGen/DeSSA.cpp b/IGC/Compiler/CISACodeGen/DeSSA.cpp -index b5d718cc6e..ce89fa53dd 100644 ---- a/IGC/Compiler/CISACodeGen/DeSSA.cpp -+++ b/IGC/Compiler/CISACodeGen/DeSSA.cpp -@@ -85,6 +85,7 @@ IN THE SOFTWARE. - #include "llvmWrapper/IR/Instructions.h" - #include - #include -+#include - #include "common/LLVMWarningsPop.hpp" - #include - #include "Probe/Assertion.h" -@@ -1319,7 +1320,7 @@ int DeSSA::checkInsertElementAlias( - // - // If found, return the actual vector size; - // otherwise, return 0. -- VectorType* VTy = cast(IEI->getType()); -+ IGCLLVM::FixedVectorType* VTy = cast(IEI->getType()); - IGC_ASSERT(nullptr != VTy); - int nelts = (int)VTy->getNumElements(); - AllIEIs.resize(nelts, nullptr); -diff --git a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp -index c68692f74e..318d290d81 100644 ---- a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp -+++ b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp -@@ -53,6 +53,7 @@ IN THE SOFTWARE. - #include "Compiler/IGCPassSupport.h" - #include "common/LLVMWarningsPush.hpp" - #include "llvmWrapper/IR/Instructions.h" -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "llvm/Support/Path.h" - #include "llvm/Support/FormattedStream.h" - #include "llvm/IR/AssemblyAnnotationWriter.h" -@@ -1229,7 +1230,7 @@ bool EmitPass::canRelocatePhiMov( - if (dst != src) - { - int numElt = 1; -- if (VectorType * vTy = dyn_cast(PN->getType())) -+ if (IGCLLVM::FixedVectorType * vTy = dyn_cast(PN->getType())) - { - numElt = int_cast(vTy->getNumElements()); - } -@@ -1366,7 +1367,7 @@ void EmitPass::MovPhiSources(llvm::BasicBlock* aBB) - phiSrcDstList.push_back(phiInfo); - - int numElt = 0; -- if (VectorType * vTy = dyn_cast(PN->getType())) -+ if (IGCLLVM::FixedVectorType * vTy = dyn_cast(PN->getType())) - { - numElt = int_cast(vTy->getNumElements()); - } -@@ -5455,7 +5456,7 @@ void EmitPass::emitLegacySimdBlockWrite(llvm::Instruction* inst, llvm::Value* pt - bool useA64 = isA64Ptr(ptrType, m_currShader->GetContext()); - - Type* Ty = dataPtr->getType(); -- VectorType* VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Ty); - uint32_t nbElements = VTy ? int_cast(VTy->getNumElements()) : 1; - - uint32_t typeSizeInBytes = Ty->getScalarSizeInBits() / 8; -@@ -5701,7 +5702,7 @@ void EmitPass::emitLegacySimdBlockRead(llvm::Instruction* inst, llvm::Value* ptr - bool useA64 = isA64Ptr(ptrType, m_currShader->GetContext()); - - Type* Ty = inst->getType(); -- VectorType* VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Ty); - uint32_t nbElements = VTy ? int_cast(VTy->getNumElements()) : 1; - - uint32_t typeSizeInBytes = Ty->getScalarSizeInBits() / 8; -@@ -5993,7 +5994,7 @@ void EmitPass::emitMediaBlockIO(const llvm::GenIntrinsicInst* inst, bool isRead) - }; - - uint nElts = isa(pDataType) ? -- (uint)cast(pDataType)->getNumElements() : -+ (uint)cast(pDataType)->getNumElements() : - 1; - - // Now, do the copies. -@@ -6083,7 +6084,7 @@ void EmitPass::emitSimdMediaBlockRead(llvm::Instruction* inst) - uint32_t nbElements = 1; - if (inst->getType()->isVectorTy()) - { -- nbElements = (uint32_t)cast(inst->getType())->getNumElements(); -+ nbElements = (uint32_t)cast(inst->getType())->getNumElements(); - } - IGC_ASSERT_MESSAGE(nbElements <= 8, "InValid Vector Size"); - -@@ -6327,7 +6328,7 @@ void EmitPass::emitSimdMediaBlockWrite(llvm::Instruction* inst) - uint32_t nbElements = 1; - if (dataPtr->getType()->isVectorTy()) - { -- nbElements = (uint32_t)cast(dataPtr->getType())->getNumElements(); -+ nbElements = (uint32_t)cast(dataPtr->getType())->getNumElements(); - } - IGC_ASSERT_MESSAGE(nbElements <= 8, "InValid Vector Size"); - -@@ -9139,8 +9140,8 @@ void EmitPass::emitBitCast(llvm::BitCastInst* btCst) - { - Type* srcType = btCst->getOperand(0)->getType(); - Type* dstType = btCst->getType(); -- unsigned int numSrcElement = srcType->isVectorTy() ? (unsigned)cast(srcType)->getNumElements() : 1; -- unsigned int numDstElement = dstType->isVectorTy() ? (unsigned)cast(dstType)->getNumElements() : 1; -+ unsigned int numSrcElement = srcType->isVectorTy() ? (unsigned)cast(srcType)->getNumElements() : 1; -+ unsigned int numDstElement = dstType->isVectorTy() ? (unsigned)cast(dstType)->getNumElements() : 1; - - if (srcType->isPointerTy()) - { -@@ -9587,7 +9588,7 @@ void EmitPass::emitLoad3DInner(LdRawIntrinsic* inst, ResourceDescriptor& resourc - { - IGC_ASSERT_MESSAGE(predDefSurface != ESURFACE_STATELESS, "scratch cannot be uniform"); - Type* loadType = inst->getType(); -- uint numElement = loadType->isVectorTy() ? (uint)cast(loadType)->getNumElements() : 1; -+ uint numElement = loadType->isVectorTy() ? (uint)cast(loadType)->getNumElements() : 1; - if (predDefSurface == ESURFACE_SLM) - { - IGC_ASSERT(numElement <= 4); -@@ -10919,7 +10920,7 @@ void EmitPass::emitInsert(llvm::Instruction* inst) - pVecVar = GetSymbol(pVec); - if (pVecVar != pInstVar) - { -- emitVectorCopy(pInstVar, pVecVar, int_cast(dyn_cast(pVecType)->getNumElements())); -+ emitVectorCopy(pInstVar, pVecVar, int_cast(dyn_cast(pVecType)->getNumElements())); - } - } - } -@@ -14753,7 +14754,7 @@ bool EmitPass::isUniformStoreOCL(llvm::StoreInst* SI) - - Value* storeVal = SI->getValueOperand(); - Type* Ty = storeVal->getType(); -- VectorType* VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Ty); - uint32_t elts = VTy ? int_cast(VTy->getNumElements()) : 1; - Type* eltTy = VTy ? VTy->getElementType() : Ty; - -@@ -14783,7 +14784,7 @@ void EmitPass::emitVectorBitCast(llvm::BitCastInst* BCI) - if (srcTy->isVectorTy()) - { - srcEltTy = cast(srcTy)->getElementType(); -- srcNElts = (uint32_t)cast(srcTy)->getNumElements(); -+ srcNElts = (uint32_t)cast(srcTy)->getNumElements(); - } - else - { -@@ -14793,7 +14794,7 @@ void EmitPass::emitVectorBitCast(llvm::BitCastInst* BCI) - if (dstTy->isVectorTy()) - { - dstEltTy = cast(dstTy)->getElementType(); -- dstNElts = (uint32_t)cast(dstTy)->getNumElements(); -+ dstNElts = (uint32_t)cast(dstTy)->getNumElements(); - } - else - { -@@ -15372,7 +15373,7 @@ void EmitPass::emitVectorLoad(LoadInst* inst, Value* offset, ConstantInt* immOff - } - - Type* Ty = inst->getType(); -- VectorType* VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Ty); - Type* eltTy = VTy ? VTy->getElementType() : Ty; - uint32_t eltBytes = GetScalarTypeSizeInRegister(eltTy); - IGC_ASSERT_MESSAGE((eltBytes == 1) || (eltBytes == 2) || (eltBytes == 4) || (eltBytes == 8), -@@ -15824,7 +15825,7 @@ void EmitPass::emitVectorStore(StoreInst* inst, Value* offset, ConstantInt* immO - - Value* storedVal = inst->getValueOperand(); - Type* Ty = storedVal->getType(); -- VectorType* VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Ty); - Type* eltTy = VTy ? VTy->getElementType() : Ty; - uint32_t eltBytes = GetScalarTypeSizeInRegister(eltTy); - -@@ -16628,7 +16629,7 @@ void EmitPass::emitCopyAll(CVariable* Dst, CVariable* Src, llvm::Type* Ty) - } - else if (Ty->isVectorTy()) - { -- unsigned NElts = (unsigned)cast(Ty)->getNumElements(); -+ unsigned NElts = (unsigned)cast(Ty)->getNumElements(); - emitVectorCopy(Dst, Src, NElts); - } - else -diff --git a/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp b/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp -index 28248f3062..767b477af1 100644 ---- a/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp -+++ b/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp -@@ -1961,7 +1961,7 @@ bool InstExpander::visitExtractElement(ExtractElementInst& EEI) { - // later. - - Value* V = EEI.getVectorOperand(); -- unsigned NumElts = (unsigned)cast(V->getType())->getNumElements(); -+ unsigned NumElts = (unsigned)cast(V->getType())->getNumElements(); - V = IRB->CreateBitCast(V, Emu->getV2Int32Ty(NumElts)); - // Re-calculate indices to Lo and Hi parts. - Value* Idx = EEI.getIndexOperand(); -@@ -1998,7 +1998,7 @@ bool InstExpander::visitInsertElement(InsertElementInst& IEI) { - - // Create the emulated vector. - Value* NewVal = IEI.getOperand(0); -- unsigned NumElts = (unsigned)cast(NewVal->getType())->getNumElements(); -+ unsigned NumElts = (unsigned)cast(NewVal->getType())->getNumElements(); - NewVal = IRB->CreateBitCast(NewVal, Emu->getV2Int32Ty(NumElts)); - // Re-calculate indices to Lo and Hi parts. - Value* Idx = IEI.getOperand(2); -diff --git a/IGC/Compiler/CISACodeGen/GenIRLowering.cpp b/IGC/Compiler/CISACodeGen/GenIRLowering.cpp -index c74a2ac6ef..78e8a4aa30 100644 ---- a/IGC/Compiler/CISACodeGen/GenIRLowering.cpp -+++ b/IGC/Compiler/CISACodeGen/GenIRLowering.cpp -@@ -453,7 +453,7 @@ Value* GEPLowering::getSExtOrTrunc(Value* Val, Type* NewTy) const { - - IGC_ASSERT_MESSAGE(OldTy->isIntOrIntVectorTy(), "Index should be Integer or vector of Integer!"); - -- if (auto OldVecTy = dyn_cast(OldTy)) { -+ if (auto OldVecTy = dyn_cast(OldTy)) { - OldWidth = (unsigned)OldVecTy->getNumElements() * OldVecTy->getElementType()->getIntegerBitWidth(); - NewWidth = (unsigned)OldVecTy->getNumElements() * NewTy->getIntegerBitWidth(); - } -@@ -805,7 +805,7 @@ bool GEPLowering::lowerGetElementPtrInst(GetElementPtrInst* GEP) const - } - else - { -- if (auto NewIdxVT = dyn_cast(NewIdx->getType())) { -+ if (auto NewIdxVT = dyn_cast(NewIdx->getType())) { - Value* result = llvm::UndefValue::get(FixedVectorType::get(PtrMathTy, (unsigned)NewIdxVT->getNumElements())); - for (uint32_t j = 0; j < (uint32_t)NewIdxVT->getNumElements(); j++) { - result = Builder->CreateInsertElement(result, PointerValue, Builder->getInt32(j)); -diff --git a/IGC/Compiler/CISACodeGen/GenSimplification.cpp b/IGC/Compiler/CISACodeGen/GenSimplification.cpp -index 8c38f2292e..f432061e64 100644 ---- a/IGC/Compiler/CISACodeGen/GenSimplification.cpp -+++ b/IGC/Compiler/CISACodeGen/GenSimplification.cpp -@@ -35,6 +35,7 @@ IN THE SOFTWARE. - #include - #include - #include -+#include - #include "common/LLVMWarningsPop.hpp" - #include "Probe/Assertion.h" - -@@ -164,7 +165,7 @@ bool GenSimplification::simplifyVectorPHINodeCase2(PHINode& PN) const { - - Type* Ty = PN.getType(); - Type* EltTy = Ty->getScalarType(); -- unsigned NumElts = (unsigned)cast(Ty)->getNumElements(); -+ unsigned NumElts = (unsigned)cast(Ty)->getNumElements(); - - SmallVector Lanes; - SmallVector, 4> Values; -@@ -238,7 +239,7 @@ void GenSimplification::visitPHINode(PHINode& PN) { - void GenSimplification::visitExtractElement(ExtractElementInst& EEI) { - // Skip non-2-element vector. - Value* Vec = EEI.getVectorOperand(); -- VectorType* VTy = cast(Vec->getType()); -+ IGCLLVM::FixedVectorType* VTy = cast(Vec->getType()); - if (VTy->getNumElements() != 2) - return; - -diff --git a/IGC/Compiler/CISACodeGen/GeometryShaderLowering.cpp b/IGC/Compiler/CISACodeGen/GeometryShaderLowering.cpp -index a5d6594820..32c4759fdb 100644 ---- a/IGC/Compiler/CISACodeGen/GeometryShaderLowering.cpp -+++ b/IGC/Compiler/CISACodeGen/GeometryShaderLowering.cpp -@@ -33,6 +33,7 @@ IN THE SOFTWARE. - #include - #include - #include -+#include - #include "common/LLVMWarningsPop.hpp" - #include "Compiler/InitializePasses.h" - #include "Probe/Assertion.h" -@@ -507,7 +508,7 @@ void GeometryShaderLowering::AddURBRead( - { - Value* vec = UndefValue::get(inst->getType()); - IRBuilder<> builder(inst); -- for (unsigned int i = 0; i < cast(inst->getType())->getNumElements(); i++) -+ for (unsigned int i = 0; i < cast(inst->getType())->getNumElements(); i++) - { - Value* vecElement = builder.CreateExtractElement(urbRead, builder.getInt32(i)); - vec = builder.CreateInsertElement(vec, vecElement, builder.getInt32(i)); -diff --git a/IGC/Compiler/CISACodeGen/LdShrink.cpp b/IGC/Compiler/CISACodeGen/LdShrink.cpp -index d89fbd0e82..2df06df2fd 100644 ---- a/IGC/Compiler/CISACodeGen/LdShrink.cpp -+++ b/IGC/Compiler/CISACodeGen/LdShrink.cpp -@@ -30,6 +30,7 @@ IN THE SOFTWARE. - #include - #include - #include -+#include - #include "common/LLVMWarningsPop.hpp" - #include "Compiler/CISACodeGen/ShaderCodeGen.hpp" - #include "Compiler/IGCPassSupport.h" -@@ -79,7 +80,7 @@ IGC_INITIALIZE_PASS_BEGIN(LdShrink, PASS_FLAG, PASS_DESC, PASS_CFG_ONLY, PASS_AN - IGC_INITIALIZE_PASS_END(LdShrink, PASS_FLAG, PASS_DESC, PASS_CFG_ONLY, PASS_ANALYSIS) - - unsigned LdShrink::getExtractIndexMask(LoadInst* LI) const { -- VectorType* VTy = dyn_cast(LI->getType()); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(LI->getType()); - // Skip non-vector loads. - if (!VTy) - return 0; -@@ -91,9 +92,12 @@ unsigned LdShrink::getExtractIndexMask(LoadInst* LI) const { - Type* Ty = VTy->getScalarType(); - // Skip non-BYTE addressable data types. So far, check integer types - // only. -- if (IntegerType * ITy = dyn_cast(Ty)) -- if (!ITy->isPowerOf2ByteWidth()) -+ if (IntegerType * ITy = dyn_cast(Ty)) { -+ // Unroll isPowerOf2ByteWidth, it was removed in LLVM 12. -+ unsigned BitWidth = ITy->getBitWidth(); -+ if (!((BitWidth > 7) && isPowerOf2_32(BitWidth))) - return 0; -+ } - - unsigned Mask = 0; // Maxmimally 32 elements. - -diff --git a/IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp b/IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp -index 43febc955a..d9c2fb3ad8 100644 ---- a/IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp -+++ b/IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp -@@ -617,7 +617,7 @@ void TransposeHelper::handleGEPInst( - } - else - { -- arr_sz = (unsigned)cast(T)->getNumElements(); -+ arr_sz = (unsigned)cast(T)->getNumElements(); - } - T = cast(T)->getElementType(); - } -@@ -639,7 +639,7 @@ void TransposeHelper::handleGEPInst( - } - else if (T->isVectorTy()) - { -- arr_sz = (unsigned)cast(T)->getNumElements(); -+ arr_sz = (unsigned)cast(T)->getNumElements(); - T = cast(T)->getElementType(); - } - else -@@ -699,7 +699,7 @@ void TransposeHelperPromote::handleLoadInst( - IRBuilder<> IRB(pLoad); - IGC_ASSERT(nullptr != pLoad->getType()); - unsigned N = pLoad->getType()->isVectorTy() -- ? (unsigned)cast(pLoad->getType())->getNumElements() -+ ? (unsigned)cast(pLoad->getType())->getNumElements() - : 1; - Value* Val = loadEltsFromVecAlloca(N, pVecAlloca, pScalarizedIdx, IRB, pLoad->getType()->getScalarType()); - pLoad->replaceAllUsesWith(Val); -@@ -731,7 +731,7 @@ void TransposeHelperPromote::handleStoreInst( - // %v1 = extractelement <2 x float> %v, i32 1 - // %w1 = insertelement <32 x float> %w0, float %v1, i32 %idx+1 - // store <32 x float> %w1, <32 x float>* %ptr1 -- for (unsigned i = 0, e = (unsigned)cast(pStoreVal->getType())->getNumElements(); i < e; ++i) -+ for (unsigned i = 0, e = (unsigned)cast(pStoreVal->getType())->getNumElements(); i < e; ++i) - { - Value* VectorIdx = ConstantInt::get(pScalarizedIdx->getType(), i); - auto Val = IRB.CreateExtractElement(pStoreVal, VectorIdx); -diff --git a/IGC/Compiler/CISACodeGen/MemOpt.cpp b/IGC/Compiler/CISACodeGen/MemOpt.cpp -index 027734c105..debb7e22ba 100644 ---- a/IGC/Compiler/CISACodeGen/MemOpt.cpp -+++ b/IGC/Compiler/CISACodeGen/MemOpt.cpp -@@ -125,7 +125,7 @@ namespace { - MemRefListTy& MemRefs, TrivialMemRefListTy& ToOpt); - - unsigned getNumElements(Type* Ty) const { -- return Ty->isVectorTy() ? (unsigned)cast(Ty)->getNumElements() : 1; -+ return Ty->isVectorTy() ? (unsigned)cast(Ty)->getNumElements() : 1; - } - - MemoryLocation getLocation(Instruction* I) const { -@@ -798,7 +798,7 @@ bool MemOpt::mergeLoad(LoadInst* LeadingLoad, - Pos = unsigned((std::get<1>(I) - FirstOffset) / LdScalarSize); - - if (Ty->isVectorTy()) { -- if (Pos + cast(Ty)->getNumElements() > NumElts) { -+ if (Pos + cast(Ty)->getNumElements() > NumElts) { - // This implies we're trying to extract an element from our new load - // with an index > the size of the new load. If this happens, - // we'll generate correct code if it does since we don't remove the -@@ -806,7 +806,7 @@ bool MemOpt::mergeLoad(LoadInst* LeadingLoad, - continue; - } - Value* Val = UndefValue::get(Ty); -- for (unsigned i = 0, e = (unsigned)cast(Ty)->getNumElements(); i != e; ++i) { -+ for (unsigned i = 0, e = (unsigned)cast(Ty)->getNumElements(); i != e; ++i) { - Value* Ex = Builder.CreateExtractElement(NewLoad, Builder.getInt32(Pos + i)); - Ex = createBitOrPointerCast(Ex, ScalarTy, Builder); - Val = Builder.CreateInsertElement(Val, Ex, Builder.getInt32(i)); -@@ -1084,7 +1084,7 @@ bool MemOpt::mergeStore(StoreInst* LeadingStore, - IGC_ASSERT(hasSameSize(ScalarTy, LeadingStoreScalarType)); - - if (Ty->isVectorTy()) { -- for (unsigned i = 0, e = (unsigned)cast(Ty)->getNumElements(); i != e; ++i) { -+ for (unsigned i = 0, e = (unsigned)cast(Ty)->getNumElements(); i != e; ++i) { - Value* Ex = Builder.CreateExtractElement(Val, Builder.getInt32(i)); - Ex = createBitOrPointerCast(Ex, LeadingStoreScalarType, Builder); - NewStoreVal = Builder.CreateInsertElement(NewStoreVal, Ex, -diff --git a/IGC/Compiler/CISACodeGen/MemOpt2.cpp b/IGC/Compiler/CISACodeGen/MemOpt2.cpp -index 4b2628d2b1..20115c73a3 100644 ---- a/IGC/Compiler/CISACodeGen/MemOpt2.cpp -+++ b/IGC/Compiler/CISACodeGen/MemOpt2.cpp -@@ -32,6 +32,7 @@ IN THE SOFTWARE. - #include - #include - #include -+#include - #include "common/LLVMWarningsPop.hpp" - #include "GenISAIntrinsics/GenIntrinsics.h" - -@@ -124,7 +125,7 @@ namespace { - if (!Ty->isSingleValueType()) - return UINT_MAX; - // Simply return 1 so far for scalar types. -- VectorType* VecTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VecTy = dyn_cast(Ty); - if (!VecTy) - return 1; - // Check how that vector is used. -@@ -153,7 +154,7 @@ namespace { - return UINT_MAX; - unsigned EltByte = (Ty->getScalarSizeInBits() + 7) / 8; - // Simply return 1 so far for scalar types. -- VectorType* VecTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VecTy = dyn_cast(Ty); - if (!VecTy) - return EltByte; - // Check how that vector is used. -diff --git a/IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp b/IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp -index 8d6d7801db..349235a812 100644 ---- a/IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp -+++ b/IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp -@@ -425,7 +425,7 @@ namespace IGC - unsigned int numElements = 1; - if (baseType->isVectorTy()) - { -- numElements = (unsigned)cast(baseType)->getNumElements(); -+ numElements = (unsigned)cast(baseType)->getNumElements(); - baseType = cast(baseType)->getElementType(); - } - -diff --git a/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp b/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp -index 4397af09c7..484e8d5c43 100644 ---- a/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp -+++ b/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp -@@ -2959,8 +2959,8 @@ namespace IGC - llvm::Type* srcTy = bTInst->getOperand(0)->getType(); - llvm::Type* dstTy = bTInst->getType(); - -- srcNElts = (srcTy->isVectorTy()) ? (uint32_t)cast(srcTy)->getNumElements() : 1; -- dstNElts = (dstTy->isVectorTy()) ? (uint32_t)cast(dstTy)->getNumElements() : 1; -+ srcNElts = (srcTy->isVectorTy()) ? (uint32_t)cast(srcTy)->getNumElements() : 1; -+ dstNElts = (dstTy->isVectorTy()) ? (uint32_t)cast(dstTy)->getNumElements() : 1; - - if (srcNElts < dstNElts && srcTy->getScalarSizeInBits() < 64) - { -diff --git a/IGC/Compiler/CISACodeGen/PushAnalysis.cpp b/IGC/Compiler/CISACodeGen/PushAnalysis.cpp -index 410fc99c0e..e61db1ffae 100644 ---- a/IGC/Compiler/CISACodeGen/PushAnalysis.cpp -+++ b/IGC/Compiler/CISACodeGen/PushAnalysis.cpp -@@ -1003,7 +1003,7 @@ namespace IGC - - if (pTypeToPush->isVectorTy()) - { -- num_elms = (unsigned)cast(pTypeToPush)->getNumElements(); -+ num_elms = (unsigned)cast(pTypeToPush)->getNumElements(); - pTypeToPush = cast(pTypeToPush)->getElementType(); - llvm::Type* pVecTy = IGCLLVM::FixedVectorType::get(pTypeToPush, num_elms); - pReplacedInst = llvm::UndefValue::get(pVecTy); -@@ -1194,7 +1194,7 @@ namespace IGC - } - - unsigned num_elms = -- inst->getType()->isVectorTy() ? (unsigned)cast(inst->getType())->getNumElements() : 1; -+ inst->getType()->isVectorTy() ? (unsigned)cast(inst->getType())->getNumElements() : 1; - llvm::Type* pTypeToPush = inst->getType(); - llvm::Value* replaceVector = nullptr; - unsigned int numberChannelReplaced = 0; -diff --git a/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp b/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp -index 95b937e735..1c6544a489 100644 ---- a/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp -+++ b/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp -@@ -41,6 +41,7 @@ IN THE SOFTWARE. - #include - #include - #include -+#include - #include "common/LLVMWarningsPop.hpp" - #include "Probe/Assertion.h" - -@@ -146,7 +147,7 @@ RegUse RegisterEstimator::estimateNumOfRegs(Value* V) const - Type* Ty = V->getType(); - if (!Ty->isVoidTy()) - { -- VectorType* VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Ty); - Type* eltTy = VTy ? VTy->getElementType() : Ty; - uint32_t nelts = VTy ? int_cast(VTy->getNumElements()) : 1; - uint32_t eltBits = (uint32_t)m_DL->getTypeSizeInBits(eltTy); -diff --git a/IGC/Compiler/CISACodeGen/RegisterPressureEstimate.hpp b/IGC/Compiler/CISACodeGen/RegisterPressureEstimate.hpp -index beac138d5a..ceeafa48fc 100644 ---- a/IGC/Compiler/CISACodeGen/RegisterPressureEstimate.hpp -+++ b/IGC/Compiler/CISACodeGen/RegisterPressureEstimate.hpp -@@ -42,6 +42,7 @@ See LRCENSE.TXT for details. - #include "llvm/Pass.h" - #include - #include "llvm/Analysis/LoopInfo.h" -+#include - #include "common/LLVMWarningsPop.hpp" - #include "Compiler/IGCPassSupport.h" - #include "Compiler/CISACodeGen/WIAnalysis.hpp" -@@ -240,7 +241,7 @@ namespace IGC - auto Ty = V->getType(); - if (Ty->isVoidTy()) - return 0; -- auto VTy = llvm::dyn_cast(Ty); -+ auto VTy = llvm::dyn_cast(Ty); - auto eltTy = VTy ? VTy->getElementType() : Ty; - uint32_t nelts = VTy ? int_cast(VTy->getNumElements()) : 1; - uint32_t eltBits = (uint32_t)m_DL->getTypeSizeInBits(eltTy); -diff --git a/IGC/Compiler/CISACodeGen/SLMConstProp.cpp b/IGC/Compiler/CISACodeGen/SLMConstProp.cpp -index 962083f453..26a7b8be21 100644 ---- a/IGC/Compiler/CISACodeGen/SLMConstProp.cpp -+++ b/IGC/Compiler/CISACodeGen/SLMConstProp.cpp -@@ -39,6 +39,7 @@ IN THE SOFTWARE. - #include - #include - #include -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "common/LLVMWarningsPop.hpp" - #include - #include "Probe/Assertion.h" -@@ -629,7 +630,7 @@ bool SLMConstProp::isEqual(Constant* C0, Constant* C1) - - bool SLMConstProp::isFloatType(Type* Ty) - { -- if (VectorType * vTy = dyn_cast(Ty)) -+ if (IGCLLVM::FixedVectorType * vTy = dyn_cast(Ty)) - { - if (vTy->getNumElements() > 1) - { -diff --git a/IGC/Compiler/CISACodeGen/ScalarizerCodeGen.cpp b/IGC/Compiler/CISACodeGen/ScalarizerCodeGen.cpp -index ce81641691..32ab79c1dd 100644 ---- a/IGC/Compiler/CISACodeGen/ScalarizerCodeGen.cpp -+++ b/IGC/Compiler/CISACodeGen/ScalarizerCodeGen.cpp -@@ -66,7 +66,7 @@ void ScalarizerCodeGen::visitBinaryOperator(llvm::BinaryOperator& I) - { - bool isNewTypeVector = false; - -- VectorType* instType = cast(I.getType()); -+ IGCLLVM::FixedVectorType* instType = cast(I.getType()); - unsigned numElements = int_cast(instType->getNumElements()); - unsigned scalarSize = instType->getScalarSizeInBits(); - unsigned newScalarBits = numElements * scalarSize; -@@ -111,7 +111,7 @@ void ScalarizerCodeGen::visitBinaryOperator(llvm::BinaryOperator& I) - } - else - { -- VectorType* newVecType = cast(newType); -+ IGCLLVM::FixedVectorType* newVecType = cast(newType); - unsigned newVecTypeNumEle = int_cast(newVecType->getNumElements()); - Value* ieLogicOp = UndefValue::get(newType); - for (unsigned i = 0; i < newVecTypeNumEle; i++) -diff --git a/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp b/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp -index 563d95173c..3b974da405 100644 ---- a/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp -+++ b/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp -@@ -638,12 +638,17 @@ static void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSi - { - mpm.add(createPruneUnusedArgumentsPass()); - -+#if LLVM_VERSION_MAJOR >= 12 -+ mpm.add(createIPSCCPPass()); -+#else - if (IGC_GET_FLAG_VALUE(FunctionControl) == FLAG_FCALL_DEFAULT) - { - // Don't run IPConstantProp when debugging function calls, to avoid folding function arg/ret constants - mpm.add(createIPConstantPropagationPass()); - } - mpm.add(createConstantPropagationPass()); -+#endif -+ - mpm.add(createDeadCodeEliminationPass()); - mpm.add(createCFGSimplificationPass()); - } -@@ -1541,8 +1546,13 @@ void OptimizeIR(CodeGenContext* const pContext) - // possible which potentially allows late stage code sinking of - // those calls by the instruction combiner. - mpm.add(createPostOrderFunctionAttrsLegacyPass()); -+ -+#if LLVM_VERSION_MAJOR >= 12 -+ mpm.add(createIPSCCPPass()); -+#else - mpm.add(createConstantPropagationPass()); - mpm.add(createIPConstantPropagationPass()); -+#endif - } - - // enable this only when Pooled EU is not supported -diff --git a/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp b/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp -index 4760b3e792..3e22f3aa68 100644 ---- a/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp -+++ b/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp -@@ -28,8 +28,10 @@ IN THE SOFTWARE. - #include "Compiler/CISACodeGen/Platform.hpp" - #include "common/LLVMWarningsPush.hpp" - #include -+#include - #include - #include -+#include - #include "common/LLVMWarningsPop.hpp" - #include "GenISAIntrinsics/GenIntrinsics.h" - #include "GenISAIntrinsics/GenIntrinsicInst.h" -@@ -577,7 +579,7 @@ static bool isPayloadHeader(Value* V) { - Argument* Arg = dyn_cast(V); - if (!Arg || !Arg->hasName()) - return false; -- VectorType* VTy = dyn_cast(Arg->getType()); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Arg->getType()); - if (!VTy || VTy->getNumElements() != 8 || - !VTy->getElementType()->isIntegerTy(32)) - return false; -@@ -588,7 +590,7 @@ static bool isR0(Value* V) { - Argument* Arg = dyn_cast(V); - if (!Arg || !Arg->hasName()) - return false; -- VectorType* VTy = dyn_cast(Arg->getType()); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Arg->getType()); - if (!VTy || VTy->getNumElements() != 8 || - !VTy->getElementType()->isIntegerTy(32)) - return false; -@@ -599,7 +601,7 @@ static bool isEnqueuedLocalSize(Value* V) { - Argument* Arg = dyn_cast(V); - if (!Arg || !Arg->hasName()) - return false; -- VectorType* VTy = dyn_cast(Arg->getType()); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Arg->getType()); - if (!VTy || VTy->getNumElements() != 3 || - !VTy->getElementType()->isIntegerTy(32)) - return false; -@@ -998,7 +1000,7 @@ static bool hasLongStridedLdStInLoop(Function* F, LoopInfo* LI, WIAnalysis* WI) - // Collect innermost simple loop. - for (auto I = LI->begin(), E = LI->end(); I != E; ++I) { - auto L = *I; -- if (!L->empty()) -+ if (!IGCLLVM::isInnermost(L)) - continue; - if (L->getNumBlocks() != 2) - continue; -diff --git a/IGC/Compiler/CISACodeGen/SimplifyConstant.cpp b/IGC/Compiler/CISACodeGen/SimplifyConstant.cpp -index 73f472b5b9..0069c4b1bb 100644 ---- a/IGC/Compiler/CISACodeGen/SimplifyConstant.cpp -+++ b/IGC/Compiler/CISACodeGen/SimplifyConstant.cpp -@@ -352,7 +352,7 @@ static unsigned getLegalVectorSize(unsigned N) { - // Check vector size. We may demote the data type if all values can fit into - // smaller data type. - // --static bool checkSize(GlobalVariable* GV, VectorType*& DataType, -+static bool checkSize(GlobalVariable* GV, IGCLLVM::FixedVectorType*& DataType, - bool& IsSigned) { - Constant* Init = GV->getInitializer(); - IGC_ASSERT(isa(Init->getType())); -@@ -360,7 +360,7 @@ static bool checkSize(GlobalVariable* GV, VectorType*& DataType, - unsigned N = (unsigned)ArrayTy->getArrayNumElements(); - Type* BaseTy = ArrayTy->getArrayElementType(); - unsigned VectorSize = 1; -- if (auto VT = dyn_cast(BaseTy)) { -+ if (auto VT = dyn_cast(BaseTy)) { - BaseTy = VT->getElementType(); - VectorSize = int_cast(VT->getNumElements()); - N *= VectorSize; -@@ -483,7 +483,7 @@ static Constant* getConstantVal(Type* VEltTy, Constant* V, bool IsSigned) { - return ConstantInt::get(VEltTy, IVal, IsSigned); - } - --static void promote(GlobalVariable* GV, VectorType* AllocaType, bool IsSigned, -+static void promote(GlobalVariable* GV, IGCLLVM::FixedVectorType* AllocaType, bool IsSigned, - Function* F) { - // Build the constant vector from constant array. - unsigned VS = int_cast(AllocaType->getNumElements()); -@@ -507,7 +507,7 @@ static void promote(GlobalVariable* GV, VectorType* AllocaType, bool IsSigned, - Constant* const Elt = CA->getAggregateElement(i); - IGC_ASSERT_MESSAGE(nullptr != Elt, "Null AggregateElement"); - if (auto EltTy = dyn_cast(Elt->getType())) { -- unsigned VectorSize = (unsigned)cast(EltTy)->getNumElements(); -+ unsigned VectorSize = (unsigned)cast(EltTy)->getNumElements(); - for (unsigned j = 0; j < VectorSize; ++j) { - Constant* V = Elt->getAggregateElement(j); - Vals[i * VectorSize + j] = getConstantVal(VEltTy, V, IsSigned); -@@ -549,7 +549,7 @@ static void promote(GlobalVariable* GV, VectorType* AllocaType, bool IsSigned, - unsigned N = 1; - Value* Offset = Index; - if (Ty->isVectorTy()) { -- N = (unsigned)cast(Ty)->getNumElements(); -+ N = (unsigned)cast(Ty)->getNumElements(); - Offset = Builder.CreateMul(Offset, ConstantInt::get(Offset->getType(), N)); - } - Value* Val = extractNElts(N, VectorData, Offset, Builder); -@@ -684,7 +684,7 @@ bool PromoteConstant::runOnFunction(Function& F) { - - // If possible demote the data into smaller type. Uses of value will be - // promoted back with ZExt or SExt. -- VectorType* AllocaType = nullptr; -+ IGCLLVM::FixedVectorType* AllocaType = nullptr; - bool IsSigned = false; - if (!checkSize(GV, AllocaType, IsSigned)) - continue; -diff --git a/IGC/Compiler/CISACodeGen/TypeDemote.cpp b/IGC/Compiler/CISACodeGen/TypeDemote.cpp -index eb7a7b6482..b04a0f6e51 100644 ---- a/IGC/Compiler/CISACodeGen/TypeDemote.cpp -+++ b/IGC/Compiler/CISACodeGen/TypeDemote.cpp -@@ -32,6 +32,7 @@ IN THE SOFTWARE. - #include - #include - #include -+#include - #include "common/LLVMWarningsPop.hpp" - #include "GenISAIntrinsics/GenIntrinsics.h" - #include "Probe/Assertion.h" -@@ -288,7 +289,7 @@ bool TypeDemote::demoteOnBasicBlock(BasicBlock* BB) const { - CastInst* CI = dyn_cast(Index); - if (CI && (CI->getOpcode() == Instruction::ZExt || - CI->getOpcode() == Instruction::SExt)) { -- unsigned VS = (unsigned)cast(EEI->getVectorOperandType())->getNumElements(); -+ unsigned VS = (unsigned)cast(EEI->getVectorOperandType())->getNumElements(); - unsigned N = (unsigned int)CI->getSrcTy()->getPrimitiveSizeInBits(); - unsigned Bound = (N < 32) ? (1U << N) : UINT32_MAX; - if (VS <= Bound) { -diff --git a/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.cpp b/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.cpp -index 1cac7b1209..12c4734e96 100644 ---- a/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.cpp -+++ b/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.cpp -@@ -28,6 +28,7 @@ IN THE SOFTWARE. - #include "Compiler/CodeGenPublic.h" - #include "common/LLVMWarningsPush.hpp" - #include -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "common/LLVMWarningsPop.hpp" - #include - #include "Probe/Assertion.h" -@@ -40,13 +41,13 @@ namespace - // If V is scalar, return 1. - // if V is vector, return the number of elements. - inline int getNumElts(Value* V) { -- VectorType* VTy = dyn_cast(V->getType()); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(V->getType()); - return VTy ? (int)VTy->getNumElements() : 1; - } - - inline int getTypeSizeInBits(Type* Ty) { - int scalarBits = Ty->getScalarSizeInBits(); -- VectorType* VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Ty); - return scalarBits * (VTy ? (int)VTy->getNumElements() : 1); - } - } -diff --git a/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.hpp b/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.hpp -index 56dac17e45..42081dcaa9 100644 ---- a/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.hpp -+++ b/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.hpp -@@ -37,6 +37,7 @@ IN THE SOFTWARE. - #include - #include - #include "llvm/Pass.h" -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "llvm/Support/raw_ostream.h" - #include "common/LLVMWarningsPop.hpp" - #include "Compiler/CISACodeGen/RegisterEstimator.hpp" -@@ -79,7 +80,7 @@ namespace IGC { - SSubVecDesc(llvm::Value* V) - : Aliaser(V), BaseVector(V), StartElementOffset(0) - { -- llvm::VectorType* VTy = llvm::dyn_cast(V->getType()); -+ IGCLLVM::FixedVectorType* VTy = llvm::dyn_cast(V->getType()); - NumElts = VTy ? (short)VTy->getNumElements() : 1; - } - -diff --git a/IGC/Compiler/CISACodeGen/VectorPreProcess.cpp b/IGC/Compiler/CISACodeGen/VectorPreProcess.cpp -index 022e0eb010..6edd19fa74 100644 ---- a/IGC/Compiler/CISACodeGen/VectorPreProcess.cpp -+++ b/IGC/Compiler/CISACodeGen/VectorPreProcess.cpp -@@ -500,7 +500,7 @@ void VectorPreProcess::replaceAllVectorUsesWithScalars(Instruction* VI, ValVecto - I = VI->getParent()->getFirstNonPHI(); - } - IRBuilder<> Builder(I); -- VectorType* VTy = cast(VI->getType()); -+ IGCLLVM::FixedVectorType* VTy = cast(VI->getType()); - Value* newVec = UndefValue::get(VTy); - for (uint32_t i = 0, e = int_cast(VTy->getNumElements()); i < e; ++i) - { -@@ -619,7 +619,7 @@ bool VectorPreProcess::splitStore( - { - Instruction* SI = ASI.getInst(); - Value* StoredVal = ASI.getValueOperand(); -- VectorType* VTy = cast(StoredVal->getType()); -+ IGCLLVM::FixedVectorType* VTy = cast(StoredVal->getType()); - Type* ETy = VTy->getElementType(); - uint32_t nelts = int_cast(VTy->getNumElements()); - -@@ -705,7 +705,7 @@ bool VectorPreProcess::splitStore( - { - Type* Ty1 = splitInfo[i].first; - uint32_t len1 = splitInfo[i].second; -- VectorType* VTy1 = dyn_cast(Ty1); -+ IGCLLVM::FixedVectorType* VTy1 = dyn_cast(Ty1); - for (uint32_t j = 0; j < len1; ++j) - { - Value* subVec; -@@ -742,7 +742,7 @@ bool VectorPreProcess::splitStore( - { - Type* Ty1 = splitInfo[i].first; - uint32_t len1 = splitInfo[i].second; -- VectorType* VTy1 = dyn_cast(Ty1); -+ IGCLLVM::FixedVectorType* VTy1 = dyn_cast(Ty1); - for (uint32_t j = 0; j < len1; ++j) - { - uint32_t vAlign = (uint32_t)MinAlign(Align, (uint32_t)eOffset * EBytes); -@@ -786,7 +786,7 @@ bool VectorPreProcess::splitLoad( - { - Instruction* LI = ALI.getInst(); - bool isLdRaw = isa(LI); -- VectorType* VTy = cast(LI->getType()); -+ IGCLLVM::FixedVectorType* VTy = cast(LI->getType()); - Type* ETy = VTy->getElementType(); - uint32_t nelts = int_cast(VTy->getNumElements()); - -@@ -848,7 +848,7 @@ bool VectorPreProcess::splitLoad( - { - Type* Ty1 = splitInfo[i].first; - uint32_t len1 = splitInfo[i].second; -- VectorType* VTy1 = dyn_cast(Ty1); -+ IGCLLVM::FixedVectorType* VTy1 = dyn_cast(Ty1); - for (uint32_t j = 0; j < len1; ++j) - { - uint32_t vAlign = (uint32_t)MinAlign(Align, eOffset * EBytes); -@@ -916,7 +916,7 @@ bool VectorPreProcess::splitLoadStore( - Optional ASI = AbstractStoreInst::get(Inst); - IGC_ASSERT_MESSAGE((ALI || ASI), "Inst should be either load or store"); - Type* Ty = ALI ? ALI->getInst()->getType() : ASI->getValueOperand()->getType(); -- VectorType* VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Ty); - if (!VTy) - { - return false; -@@ -1147,7 +1147,7 @@ void VectorPreProcess::getOrGenScalarValues( - { - availBeforeInst = nullptr; - -- VectorType* VTy = cast(VecVal->getType()); -+ IGCLLVM::FixedVectorType* VTy = cast(VecVal->getType()); - if (!VTy) - { - scalars[0] = VecVal; -@@ -1298,7 +1298,7 @@ Instruction* VectorPreProcess::simplifyLoadStore(Instruction* Inst) - // - // TODO: further optimize this load into a message with channel masks - // for cases in which use indices are sparse like {0, 2}. -- unsigned N = (unsigned)cast(Inst->getType())->getNumElements(); -+ unsigned N = (unsigned)cast(Inst->getType())->getNumElements(); - if (N == MaxIndex + 1) - return Inst; - -@@ -1404,7 +1404,7 @@ Instruction* VectorPreProcess::simplifyLoadStore(Instruction* Inst) - if (NBits < 32) - return Inst; - -- unsigned N = (unsigned)cast(Val->getType())->getNumElements(); -+ unsigned N = (unsigned)cast(Val->getType())->getNumElements(); - if (auto CV = dyn_cast(Val)) - { - unsigned MaxIndex = 0; -@@ -1573,7 +1573,7 @@ bool VectorPreProcess::runOnFunction(Function& F) - for (uint32_t j = 0; j < svals.size(); ++j) - { - Type* Ty1 = svals[j]->getType(); -- VectorType* VTy1 = dyn_cast(Ty1); -+ IGCLLVM::FixedVectorType* VTy1 = dyn_cast(Ty1); - if (VTy1) { - for (uint32_t k = 0; k < VTy1->getNumElements(); ++k) - { -@@ -1622,7 +1622,7 @@ bool VectorPreProcess::runOnFunction(Function& F) - // If this is a 3-element vector load, remove it - // from m_Vector3List as well. - if (isAbstractLoadInst(tInst) && tInst->getType()->isVectorTy() && -- cast(tInst->getType())->getNumElements() == 3) -+ cast(tInst->getType())->getNumElements() == 3) - { - InstWorkVector::iterator - tI = m_Vector3List.begin(), -diff --git a/IGC/Compiler/CISACodeGen/VectorProcess.cpp b/IGC/Compiler/CISACodeGen/VectorProcess.cpp -index 9f39cdc0d7..cfe45321d2 100644 ---- a/IGC/Compiler/CISACodeGen/VectorProcess.cpp -+++ b/IGC/Compiler/CISACodeGen/VectorProcess.cpp -@@ -240,7 +240,7 @@ bool VectorProcess::reLayoutLoadStore(Instruction* Inst) - IGC_ASSERT(nullptr != Ptr); - IGC_ASSERT(nullptr != Ty); - -- VectorType* const VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* const VTy = dyn_cast(Ty); - - // Treat a scalar as 1-element vector - uint32_t nelts = VTy ? int_cast(VTy->getNumElements()) : 1; -@@ -654,7 +654,7 @@ void VectorMessage::getInfo(Type* Ty, uint32_t Align, bool useA32, - VectorType* VTy = dyn_cast(Ty); - Type* eTy = VTy ? cast(VTy)->getElementType() : Ty; - unsigned eltSize = m_emitter->GetScalarTypeSizeInRegister(eTy); -- unsigned nElts = VTy ? (unsigned)cast(VTy)->getNumElements() : 1; -+ unsigned nElts = VTy ? (unsigned)cast(VTy)->getNumElements() : 1; - // total bytes - const unsigned TBytes = nElts * eltSize; - -diff --git a/IGC/Compiler/CISACodeGen/helper.cpp b/IGC/Compiler/CISACodeGen/helper.cpp -index 5719fd3ab8..4dc83c9f1e 100644 ---- a/IGC/Compiler/CISACodeGen/helper.cpp -+++ b/IGC/Compiler/CISACodeGen/helper.cpp -@@ -1647,7 +1647,7 @@ namespace IGC - { - instList[i] = builder.CreateExtractElement(val, static_cast(0)); - size_t iOld = i; -- for (unsigned j = 1; j < cast(val->getType())->getNumElements(); j++) -+ for (unsigned j = 1; j < cast(val->getType())->getNumElements(); j++) - { - instList.insert(instList.begin()+ iOld +j, builder.CreateExtractElement(val, j)); - i++; -@@ -1680,7 +1680,7 @@ namespace IGC - } - break; - case IGCLLVM::VectorTyID: -- num = (unsigned)cast(type)->getNumElements(); -+ num = (unsigned)cast(type)->getNumElements(); - for (unsigned i = 0; i < num; i++) - { - ScalarizeAggregateMembers(builder, builder.CreateExtractElement(val, i), instList); -@@ -1720,7 +1720,7 @@ namespace IGC - } - break; - case IGCLLVM::VectorTyID: -- num = (unsigned)cast(type)->getNumElements(); -+ num = (unsigned)cast(type)->getNumElements(); - for (unsigned i = 0; i < num; i++) - { - indices.push_back(builder.getInt32(i)); -@@ -1985,8 +1985,8 @@ namespace IGC - return false; - } - -- VectorType* dVTy = dyn_cast(dTy); -- VectorType* sVTy = dyn_cast(sTy); -+ IGCLLVM::FixedVectorType* dVTy = dyn_cast(dTy); -+ IGCLLVM::FixedVectorType* sVTy = dyn_cast(sTy); - int d_nelts = dVTy ? (int)dVTy->getNumElements() : 1; - int s_nelts = sVTy ? (int)sVTy->getNumElements() : 1; - if (d_nelts != s_nelts) { -diff --git a/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp b/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp -index 07817f05f7..15bbb0400e 100644 ---- a/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp -+++ b/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp -@@ -153,15 +153,15 @@ void ConvertMSAAPayloadTo16Bit::visitCallInst(CallInst& I) - // There are uses of ldmcs other then ldms, using vector of int32 type. - // Fix them to use newly created 16bit ldmcs. - if (ldmcs->getType()->isVectorTy() && -- ldmcs->getType()->getVectorElementType() == m_builder->getInt32Ty()) -+ cast(ldmcs->getType())->getElementType()->isFloatTy()) - { - m_builder->SetInsertPoint(ldmcs); - -- uint ldmcsNumOfElements = ldmcs->getType()->getVectorNumElements(); -- uint newLdmcsNumOfElements = new_mcs_call->getType()->getVectorNumElements(); -+ uint ldmcsNumOfElements = (uint)cast(ldmcs->getType())->getNumElements(); -+ uint newLdmcsNumOfElements = (uint)cast(new_mcs_call->getType())->getNumElements(); - - // vec of 16bit ints to vec of 32bit ints -- Type* newLdmcsVecType = VectorType::get(m_builder->getInt32Ty(), newLdmcsNumOfElements); -+ Type* newLdmcsVecType = IGCLLVM::FixedVectorType::get(m_builder->getInt32Ty(), newLdmcsNumOfElements); - Value* ldmcsExtendedToInt32 = m_builder->CreateSExt(new_mcs_call, newLdmcsVecType); - - // if ldmcs has fewer elements than new ldmcs, extend vector -@@ -175,7 +175,7 @@ void ConvertMSAAPayloadTo16Bit::visitCallInst(CallInst& I) - } - auto* pMask = ConstantDataVector::get(I.getContext(), maskVals); - -- ldmcsInt32CorrectlySized = m_builder->CreateShuffleVector(ldmcsExtendedToInt32, UndefValue::get(VectorType::get(m_builder->getInt32Ty(), ldmcsNumOfElements)), pMask); -+ ldmcsInt32CorrectlySized = m_builder->CreateShuffleVector(ldmcsExtendedToInt32, UndefValue::get(IGCLLVM::FixedVectorType::get(m_builder->getInt32Ty(), ldmcsNumOfElements)), pMask); - } - else - { -diff --git a/IGC/Compiler/CustomSafeOptPass.cpp b/IGC/Compiler/CustomSafeOptPass.cpp -index 83a6968d89..5752382ce5 100644 ---- a/IGC/Compiler/CustomSafeOptPass.cpp -+++ b/IGC/Compiler/CustomSafeOptPass.cpp -@@ -1372,7 +1372,7 @@ void IGC::CustomSafeOptPass::visitSampleBptr(llvm::SampleIntrinsic* sampleInst) - bool CustomSafeOptPass::isIdentityMatrix(ExtractElementInst& I) - { - bool found = false; -- auto extractType = cast(I.getVectorOperandType()); -+ auto extractType = cast(I.getVectorOperandType()); - auto extractTypeVecSize = (uint32_t)extractType->getNumElements(); - if (extractTypeVecSize == 20 || - extractTypeVecSize == 16) -@@ -1601,7 +1601,7 @@ void CustomSafeOptPass::visitExtractElementInst(ExtractElementInst& I) - int elOffset = (int)(bitShift / eltSize); - elOffset = rightShift ? elOffset : -elOffset; - unsigned int newIndex = (unsigned int)((int)cstIndex->getZExtValue() + elOffset); -- if (newIndex < cast(vecType)->getNumElements()) -+ if (newIndex < cast(vecType)->getNumElements()) - { - IRBuilder<> builder(&I); - Value* newBitCast = builder.CreateBitCast(binOp->getOperand(0), vecType); -@@ -2001,7 +2001,7 @@ void GenSpecificPattern::createBitcastExtractInsertPattern(BinaryOperator& I, Va - else if (auto IEIInst = dyn_cast(Op)) - { - auto opType = IEIInst->getType(); -- if (opType->isVectorTy() && cast(opType)->getElementType()->isIntegerTy(32) && cast(opType)->getNumElements() == 2) -+ if (opType->isVectorTy() && cast(opType)->getElementType()->isIntegerTy(32) && cast(opType)->getNumElements() == 2) - { - elem = IEIInst->getOperand(1); - } -@@ -2064,7 +2064,7 @@ void GenSpecificPattern::visitBinaryOperator(BinaryOperator& I) - else if (match(&I, pattern2) && AndOp2->getType()->isIntegerTy(64)) - { - ConstantVector* cVec = dyn_cast(VecOp); -- VectorType* vector_type = dyn_cast(VecOp->getType()); -+ IGCLLVM::FixedVectorType* vector_type = dyn_cast(VecOp->getType()); - if (cVec && vector_type && - isa(cVec->getOperand(0)) && - cast(cVec->getOperand(0))->isZero() && -@@ -2210,7 +2210,7 @@ void GenSpecificPattern::visitBinaryOperator(BinaryOperator& I) - BitCastInst* opBC = cast(op); - - auto opType = opBC->getType(); -- if (!(opType->isVectorTy() && cast(opType)->getElementType()->isIntegerTy(32) && cast(opType)->getNumElements() == 2)) -+ if (!(opType->isVectorTy() && cast(opType)->getElementType()->isIntegerTy(32) && cast(opType)->getNumElements() == 2)) - return nullptr; - - if (opBC->getSrcTy()->isDoubleTy()) -@@ -2630,8 +2630,8 @@ void GenSpecificPattern::visitBitCastInst(BitCastInst& I) - if (zExtInst->getOperand(0)->getType()->isIntegerTy(32) && - isa(bitCastInst->getOperand(0)) && - bitCastInst->getOperand(0)->getType()->isVectorTy() && -- cast(bitCastInst->getOperand(0)->getType())->getElementType()->isIntegerTy(32) && -- cast(bitCastInst->getOperand(0)->getType())->getNumElements() == 2) -+ cast(bitCastInst->getOperand(0)->getType())->getElementType()->isIntegerTy(32) && -+ cast(bitCastInst->getOperand(0)->getType())->getNumElements() == 2) - { - InsertElementInst* insertElementInst = cast(bitCastInst->getOperand(0)); - -@@ -2731,7 +2731,7 @@ void GenSpecificPattern::visitFNeg(llvm::UnaryOperator& I) - } - else - { -- uint32_t vectorSize = cast(I.getType())->getNumElements(); -+ uint32_t vectorSize = cast(I.getType())->getNumElements(); - fsub = llvm::UndefValue::get(I.getType()); - - for (uint32_t i = 0; i < vectorSize; ++i) -@@ -2845,7 +2845,7 @@ Constant* IGCConstProp::replaceShaderConstant(LoadInst* inst) - if (inst->getType()->isVectorTy()) - { - Type* srcEltTy = cast(inst->getType())->getElementType(); -- uint32_t srcNElts = (uint32_t)cast(inst->getType())->getNumElements(); -+ uint32_t srcNElts = (uint32_t)cast(inst->getType())->getNumElements(); - uint32_t eltSize_in_bytes = (unsigned int)srcEltTy->getPrimitiveSizeInBits() / 8; - IRBuilder<> builder(inst); - Value* vectorValue = UndefValue::get(inst->getType()); -@@ -3130,7 +3130,7 @@ Constant* IGCConstProp::ConstantFoldCmpInst(CmpInst* CI) - { - bool AllTrue = true, AllFalse = true; - auto VecOpnd = cast(EEI->getVectorOperand()); -- unsigned N = (unsigned)cast(VecOpnd->getType())->getNumElements(); -+ unsigned N = (unsigned)cast(VecOpnd->getType())->getNumElements(); - for (unsigned i = 0; i < N; ++i) - { - Constant* const Opnd = VecOpnd->getAggregateElement(i); -@@ -3926,8 +3926,8 @@ namespace IGC - BitCastInst* BC = dyn_cast(&*BI++); - if (!BC) continue; - // Skip non-element-wise bitcast. -- VectorType* DstVTy = dyn_cast(BC->getType()); -- VectorType* SrcVTy = dyn_cast(BC->getOperand(0)->getType()); -+ IGCLLVM::FixedVectorType* DstVTy = dyn_cast(BC->getType()); -+ IGCLLVM::FixedVectorType* SrcVTy = dyn_cast(BC->getOperand(0)->getType()); - if (!DstVTy || !SrcVTy || DstVTy->getNumElements() != SrcVTy->getNumElements()) - continue; - // Skip if it's not used only all extractelement. -@@ -4697,7 +4697,7 @@ void SplitIndirectEEtoSel::visitExtractElementInst(llvm::ExtractElementInst& I) - { - using namespace llvm::PatternMatch; - -- VectorType* vecTy = I.getVectorOperandType(); -+ IGCLLVM::FixedVectorType* vecTy = dyn_cast(I.getVectorOperandType()); - uint64_t num = vecTy->getNumElements(); - Type* eleType = vecTy->getElementType(); - -diff --git a/IGC/Compiler/DebugInfo/ScalarVISAModule.cpp b/IGC/Compiler/DebugInfo/ScalarVISAModule.cpp -index 194696e75b..62440d6fdb 100644 ---- a/IGC/Compiler/DebugInfo/ScalarVISAModule.cpp -+++ b/IGC/Compiler/DebugInfo/ScalarVISAModule.cpp -@@ -32,6 +32,7 @@ IN THE SOFTWARE. - #include "DebugInfo/DebugInfoUtils.hpp" - - #include "common/LLVMWarningsPush.hpp" -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "llvm/IR/Function.h" - #include "llvm/IR/Module.h" - #include "common/LLVMWarningsPop.hpp" -@@ -583,7 +584,7 @@ ScalarVisaModule::GetVariableLocation(const llvm::Instruction* pInst) const - - if (pType->isVectorTy()) - { -- vectorNumElements = (unsigned)cast(pType)->getNumElements(); -+ vectorNumElements = (unsigned)cast(pType)->getNumElements(); - } - else if (!pVar->IsUniform()) - { -diff --git a/IGC/Compiler/GenTTI.cpp b/IGC/Compiler/GenTTI.cpp -index b63eaeb0f0..e6b9120de9 100644 ---- a/IGC/Compiler/GenTTI.cpp -+++ b/IGC/Compiler/GenTTI.cpp -@@ -37,6 +37,7 @@ IN THE SOFTWARE. - #include "llvm/Analysis/LoopInfo.h" - #include "llvm/Analysis/ScalarEvolution.h" - #include "llvm/Support/raw_ostream.h" -+#include "llvmWrapper/Transforms/Utils/LoopUtils.h" - #include "common/LLVMWarningsPop.hpp" - - using namespace llvm; -@@ -224,7 +225,7 @@ namespace llvm { - - // Skip non-simple loop. - if (L->getNumBlocks() != 1) { -- if (IGC_IS_FLAG_ENABLED(EnableAdvRuntimeUnroll) && L->empty()) { -+ if (IGC_IS_FLAG_ENABLED(EnableAdvRuntimeUnroll) && IGCLLVM::isInnermost(L)) { - auto countNonPHI = [](BasicBlock* BB) { - unsigned Total = BB->size(); - unsigned PHIs = 0; -diff --git a/IGC/Compiler/GenUpdateCB.cpp b/IGC/Compiler/GenUpdateCB.cpp -index 9fb8362951..cbc25b484c 100644 ---- a/IGC/Compiler/GenUpdateCB.cpp -+++ b/IGC/Compiler/GenUpdateCB.cpp -@@ -24,6 +24,7 @@ IN THE SOFTWARE. - - #include "common/LLVMWarningsPush.hpp" - #include "llvmWrapper/Bitcode/BitcodeWriter.h" -+#include "llvmWrapper/IR/DerivedTypes.h" - #include - #include - #include "llvm/IR/DebugInfo.h" -@@ -384,7 +385,7 @@ bool GenUpdateCB::runOnFunction(Function& F) - isResInfo(dyn_cast(inst, - GenISAIntrinsic::GenISA_resinfoptr), texId, lod, isUAV)) - { -- unsigned nelems = (unsigned)cast(inst->getType())->getNumElements(); -+ unsigned nelems = (unsigned)cast(inst->getType())->getNumElements(); - SmallVector< SmallVector, 4> extracts(nelems); - if (VectorUsedByConstExtractOnly(inst, extracts)) - { -diff --git a/IGC/Compiler/HandleFRemInstructions.cpp b/IGC/Compiler/HandleFRemInstructions.cpp -index 94995a56d8..4523f3f02d 100644 ---- a/IGC/Compiler/HandleFRemInstructions.cpp -+++ b/IGC/Compiler/HandleFRemInstructions.cpp -@@ -28,6 +28,7 @@ IN THE SOFTWARE. - #include - #include - #include -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "common/LLVMWarningsPop.hpp" - #include "Compiler/IGCPassSupport.h" - #include "Probe/Assertion.h" -@@ -77,7 +78,7 @@ void HandleFRemInstructions::visitFRem(llvm::BinaryOperator& I) - - if (ValType->isVectorTy()) - { -- auto VecCount = cast(ValType)->getNumElements(); -+ auto VecCount = cast(ValType)->getNumElements(); - if (VecCount == 2 || VecCount == 3 || VecCount == 4 || VecCount == 8 || VecCount == 16) - { - VecStr = "v" + std::to_string(VecCount); -diff --git a/IGC/Compiler/HandleLoadStoreInstructions.cpp b/IGC/Compiler/HandleLoadStoreInstructions.cpp -index d18eec7311..c5535701ad 100644 ---- a/IGC/Compiler/HandleLoadStoreInstructions.cpp -+++ b/IGC/Compiler/HandleLoadStoreInstructions.cpp -@@ -77,7 +77,7 @@ void HandleLoadStoreInstructions::visitLoadInst(llvm::LoadInst& I) - - if (I.getType()->isVectorTy()) - { -- numVectorElements = (uint32_t)cast(I.getType())->getNumElements(); -+ numVectorElements = (uint32_t)cast(I.getType())->getNumElements(); - doubleDstType = IGCLLVM::FixedVectorType::get(builder.getDoubleTy(), numVectorElements); - } - uint as = ptrv->getType()->getPointerAddressSpace(); -@@ -163,7 +163,7 @@ void HandleLoadStoreInstructions::visitStoreInst(llvm::StoreInst& I) - - if (I.getValueOperand()->getType()->isVectorTy()) - { -- numVectorElements = (uint32_t)cast(I.getValueOperand()->getType())->getNumElements(); -+ numVectorElements = (uint32_t)cast(I.getValueOperand()->getType())->getNumElements(); - } - - -diff --git a/IGC/Compiler/LegalizationPass.cpp b/IGC/Compiler/LegalizationPass.cpp -index c76f3f0e1b..31e2079a9a 100644 ---- a/IGC/Compiler/LegalizationPass.cpp -+++ b/IGC/Compiler/LegalizationPass.cpp -@@ -671,7 +671,7 @@ void Legalization::visitBitCastInst(llvm::BitCastInst& I) - if (!isa(pZ->getOperand(0))) - return; - -- auto* pVecTy = cast(pZ->getDestTy()); -+ auto* pVecTy = cast(pZ->getDestTy()); - if (pVecTy->getNumElements() != 3) - return; - -@@ -766,7 +766,7 @@ void Legalization::visitSelectInst(SelectInst& I) - } - else if (I.getType()->isVectorTy()) - { -- unsigned int vecSize = (unsigned)cast(I.getType())->getNumElements(); -+ unsigned int vecSize = (unsigned)cast(I.getType())->getNumElements(); - Value* newVec = UndefValue::get(I.getType()); - m_builder->SetInsertPoint(&I); - for (unsigned int i = 0; i < vecSize; i++) -@@ -1148,7 +1148,7 @@ void Legalization::visitStoreInst(StoreInst& I) - if (ConstantDataVector * vec = dyn_cast(I.getOperand(0))) - { - Value* newVec = UndefValue::get(vec->getType()); -- unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); -+ unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); - for (unsigned int i = 0; i < nbElement; i++) - { - Constant* cst = vec->getElementAsConstant(i); -@@ -1169,7 +1169,7 @@ void Legalization::visitStoreInst(StoreInst& I) - else if (ConstantVector * vec = dyn_cast(I.getOperand(0))) - { - Value* newVec = UndefValue::get(vec->getType()); -- unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); -+ unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); - for (unsigned int i = 0; i < nbElement; i++) - { - Constant* cst = vec->getOperand(i); -@@ -1190,7 +1190,7 @@ void Legalization::visitStoreInst(StoreInst& I) - else if (ConstantAggregateZero * vec = dyn_cast(I.getOperand(0))) - { - Value* newVec = UndefValue::get(vec->getType()); -- unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); -+ unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); - for (unsigned int i = 0; i < nbElement; i++) - { - Constant* cst = vec->getElementValue(i); -@@ -1341,7 +1341,7 @@ void Legalization::visitInsertElementInst(InsertElementInst& I) - if (ConstantDataVector * vec = dyn_cast(I.getOperand(0))) - { - Value* newVec = UndefValue::get(vec->getType()); -- unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); -+ unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); - for (unsigned int i = 0; i < nbElement; i++) - { - Constant* cst = vec->getElementAsConstant(i); -@@ -1361,7 +1361,7 @@ void Legalization::visitInsertElementInst(InsertElementInst& I) - else if (ConstantVector * vec = dyn_cast(I.getOperand(0))) - { - Value* newVec = UndefValue::get(I.getType()); -- unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); -+ unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); - for (unsigned int i = 0; i < nbElement; i++) - { - Constant* cst = vec->getOperand(i); -@@ -1381,7 +1381,7 @@ void Legalization::visitInsertElementInst(InsertElementInst& I) - else if (ConstantAggregateZero * vec = dyn_cast(I.getOperand(0))) - { - Value* newVec = UndefValue::get(I.getType()); -- unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); -+ unsigned int nbElement = (unsigned)cast(vec->getType())->getNumElements(); - for (unsigned int i = 0; i < nbElement; i++) - { - Constant* cst = vec->getElementValue(i); -@@ -1398,7 +1398,7 @@ void Legalization::visitInsertElementInst(InsertElementInst& I) - else if (I.getOperand(1)->getType()->isIntegerTy(1)) - { - // This promotes i1 insertelement to i32 -- unsigned int nbElement = (unsigned)cast(I.getOperand(0)->getType())->getNumElements(); -+ unsigned int nbElement = (unsigned)cast(I.getOperand(0)->getType())->getNumElements(); - Value* newVec = UndefValue::get(IGCLLVM::FixedVectorType::get(m_builder->getInt32Ty(), nbElement)); - PromoteInsertElement(&I, newVec); - } -@@ -1411,7 +1411,7 @@ void Legalization::visitShuffleVectorInst(ShuffleVectorInst& I) - // If the original vector is a constant, just use the scalar constant, - // otherwise extract from the original vector. - -- VectorType* resType = cast(I.getType()); -+ IGCLLVM::FixedVectorType* resType = cast(I.getType()); - Value* newVec = UndefValue::get(resType); - Value* src0 = I.getOperand(0); - Value* src1 = I.getOperand(1); -@@ -1422,7 +1422,7 @@ void Legalization::visitShuffleVectorInst(ShuffleVectorInst& I) - Constant* mask = I.getShuffleMaskForBitcode(); - #endif - // The two inputs are guaranteed to be of the same type -- VectorType* inType = cast(src0->getType()); -+ IGCLLVM::FixedVectorType* inType = cast(src0->getType()); - int inCount = int_cast(inType->getNumElements()); - int inBase = 2; // 2 means using undef - // if inType == resType, use src0/src1 as the input -@@ -1638,7 +1638,7 @@ Type* Legalization::LegalAllocaType(Type* type) const - #endif - legalType = IGCLLVM::FixedVectorType::get( - LegalAllocaType(cast(type)->getElementType()), -- (unsigned)cast(type)->getNumElements()); -+ (unsigned)cast(type)->getNumElements()); - break; - case Type::StructTyID: - return LegalStructAllocaType(type); -@@ -1938,7 +1938,7 @@ void Legalization::visitIntrinsicInst(llvm::IntrinsicInst& I) - Value* newValue = nullptr; - if (srcType->isVectorTy()) - { -- auto sourceVT = cast(srcType); -+ auto sourceVT = cast(srcType); - const unsigned int numElements = (uint32_t)sourceVT->getNumElements(); - Value* dstVec = UndefValue::get(srcType); - for (unsigned int i = 0; i < numElements; ++i) -@@ -2081,7 +2081,7 @@ void Legalization::visitTruncInst(llvm::TruncInst& I) { - } - - Src = BC->getOperand(0); -- VectorType* VTy = dyn_cast(Src->getType()); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Src->getType()); - // Bail out if it's not bitcasted from <3 x i16> - if (!VTy || VTy->getNumElements() != 3 || !VTy->getElementType()->isIntegerTy(16)) - return; -diff --git a/IGC/Compiler/Legalizer/InstPromoter.cpp b/IGC/Compiler/Legalizer/InstPromoter.cpp -index bba1d96d94..63cbccb53b 100644 ---- a/IGC/Compiler/Legalizer/InstPromoter.cpp -+++ b/IGC/Compiler/Legalizer/InstPromoter.cpp -@@ -25,6 +25,7 @@ IN THE SOFTWARE. - #define DEBUG_TYPE "type-legalizer" - #include "TypeLegalizer.h" - #include "InstPromoter.h" -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "common/LLVMWarningsPush.hpp" - #include "llvm/Support/Debug.h" - #include "llvm/Support/MathExtras.h" -@@ -394,10 +395,10 @@ bool InstPromoter::visitBitCastInst(BitCastInst& I) { - unsigned N = - Val->getType()->getScalarSizeInBits() / DestTy->getScalarSizeInBits(); - Value* BC = -- IRB->CreateBitCast(Val, VectorType::get(DestTy->getScalarType(), N)); -+ IRB->CreateBitCast(Val, IGCLLVM::FixedVectorType::get(DestTy->getScalarType(), N)); - - std::vector Vals; -- for (unsigned i = 0; i < DestTy->getVectorNumElements(); i++) -+ for (unsigned i = 0; i < cast(DestTy)->getNumElements(); i++) - Vals.push_back(IRB->getInt32(i)); - - Value* Mask = ConstantVector::get(Vals); -diff --git a/IGC/Compiler/Legalizer/InstScalarizer.cpp b/IGC/Compiler/Legalizer/InstScalarizer.cpp -index 3902f74071..c8e18cc5e7 100644 ---- a/IGC/Compiler/Legalizer/InstScalarizer.cpp -+++ b/IGC/Compiler/Legalizer/InstScalarizer.cpp -@@ -130,7 +130,7 @@ bool InstScalarizer::visitLoadInst(LoadInst& I) { - // otherwise, it's broken. - IGC_ASSERT(TL->getTypeSizeInBits(EltTy) == TL->getTypeStoreSizeInBits(EltTy)); - -- unsigned NumElts = (unsigned)cast(OrigTy)->getNumElements(); -+ unsigned NumElts = (unsigned)cast(OrigTy)->getNumElements(); - unsigned Elt = 0; - - Type* NewPtrTy = PointerType::get(EltTy, AS); -@@ -268,7 +268,7 @@ bool InstScalarizer::visitStoreInst(StoreInst& I) { - // otherwise, it's broken. - IGC_ASSERT(TL->getTypeSizeInBits(EltTy) == TL->getTypeStoreSizeInBits(EltTy)); - -- unsigned NumElts = (unsigned)cast(OrigTy)->getNumElements(); -+ unsigned NumElts = (unsigned)cast(OrigTy)->getNumElements(); - unsigned Elt = 0; - - Type* NewPtrTy = PointerType::get(EltTy, AS); -@@ -498,7 +498,7 @@ bool InstScalarizer::visitInsertElementInst(InsertElementInst& I) { - IGC_ASSERT(EltSeq->size()); - IGC_ASSERT(VecSeqCopy.size() % EltSeq->size() == 0); - -- unsigned NumElts = (unsigned)cast(I.getOperand(0)->getType())->getNumElements(); -+ unsigned NumElts = (unsigned)cast(I.getOperand(0)->getType())->getNumElements(); - unsigned i = 0; - for (unsigned Elt = 0; Elt != NumElts; ++Elt) { - if (Elt == Idx) { -diff --git a/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp b/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp -index 28f8ce840f..778132c4f2 100644 ---- a/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp -+++ b/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp -@@ -162,7 +162,7 @@ void PeepholeTypeLegalizer::legalizePhiInstruction(Instruction& I) - - if (quotient > 1) - { -- unsigned numElements = I.getType()->isVectorTy() ? (unsigned)cast(I.getType())->getNumElements() : 1; -+ unsigned numElements = I.getType()->isVectorTy() ? (unsigned)cast(I.getType())->getNumElements() : 1; - Type* newType = IGCLLVM::FixedVectorType::get(Type::getIntNTy(I.getContext(), promoteToInt), quotient * numElements); - - PHINode* newPhi = m_builder->CreatePHI(newType, oldPhi->getNumIncomingValues()); -@@ -223,7 +223,7 @@ void PeepholeTypeLegalizer::legalizeExtractElement(Instruction& I) - unsigned elementWidth = extract->getType()->getScalarSizeInBits(); - if (!isLegalInteger(elementWidth) && extract->getType()->isIntOrIntVectorTy()) - { -- unsigned numElements = (unsigned)cast(extract->getOperand(0)->getType())->getNumElements(); -+ unsigned numElements = (unsigned)cast(extract->getOperand(0)->getType())->getNumElements(); - unsigned quotient, promoteToInt; - promoteInt(elementWidth, quotient, promoteToInt, DL->getLargestLegalIntTypeSizeInBits()); - -@@ -850,7 +850,7 @@ void PeepholeTypeLegalizer::cleanupZExtInst(Instruction& I) { - } - - unsigned ipElmtSize = prevInst->getOperand(0)->getType()->getScalarSizeInBits(); -- unsigned ipVecSize = (unsigned)cast(prevInst->getOperand(0)->getType())->getNumElements(); -+ unsigned ipVecSize = (unsigned)cast(prevInst->getOperand(0)->getType())->getNumElements(); - unsigned convFactor = promoteToInt / ipElmtSize; - - Value* vecRes = UndefValue::get(IGCLLVM::FixedVectorType::get(llvm::Type::getIntNTy(I.getContext(), promoteToInt), quotient)); -diff --git a/IGC/Compiler/Legalizer/TypeLegalizer.cpp b/IGC/Compiler/Legalizer/TypeLegalizer.cpp -index f8f71d71dd..a46f42bd0d 100644 ---- a/IGC/Compiler/Legalizer/TypeLegalizer.cpp -+++ b/IGC/Compiler/Legalizer/TypeLegalizer.cpp -@@ -32,6 +32,7 @@ IN THE SOFTWARE. - #include "InstScalarizer.h" - #include "InstElementizer.h" - #include "common/LLVMWarningsPush.hpp" -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "llvm/ADT/PostOrderIterator.h" - #include "llvm/IR/CFG.h" - #include "llvm/Support/Debug.h" -@@ -290,7 +291,7 @@ TypeSeq* TypeLegalizer::getScalarizedTypeSeq(Type* Ty) { - } - - Type* EltTy = cast(Ty)->getElementType(); -- for (unsigned i = 0, e = (unsigned)cast(Ty)->getNumElements(); i != e; ++i) -+ for (unsigned i = 0, e = (unsigned)cast(Ty)->getNumElements(); i != e; ++i) - TMI->second.push_back(EltTy); - - return &TMI->second; -diff --git a/IGC/Compiler/Legalizer/TypeLegalizer.h b/IGC/Compiler/Legalizer/TypeLegalizer.h -index f3ce264ce8..a6910d0876 100644 ---- a/IGC/Compiler/Legalizer/TypeLegalizer.h -+++ b/IGC/Compiler/Legalizer/TypeLegalizer.h -@@ -28,6 +28,7 @@ IN THE SOFTWARE. - #include "llvmWrapper/IR/Instructions.h" - #include "llvmWrapper/Analysis/InlineCost.h" - #include "llvmWrapper/IR/InstrTypes.h" -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "llvmWrapper/Support/Alignment.h" - #include "llvm/ADT/ArrayRef.h" - #include "llvm/ADT/DenseMap.h" -@@ -287,7 +288,7 @@ namespace IGC { - if (!Ty->isVectorTy()) - return false; - -- unsigned NumElts = (unsigned)cast(Ty)->getNumElements(); -+ unsigned NumElts = (unsigned)cast(Ty)->getNumElements(); - Type* EltTy = cast(Ty)->getElementType(); - const auto& ProfitLengths = getProfitLoadVectorLength(EltTy); - -diff --git a/IGC/Compiler/LowPrecisionOptPass.cpp b/IGC/Compiler/LowPrecisionOptPass.cpp -index 0708bfae58..15272b8dfc 100644 ---- a/IGC/Compiler/LowPrecisionOptPass.cpp -+++ b/IGC/Compiler/LowPrecisionOptPass.cpp -@@ -252,7 +252,7 @@ bool LowPrecisionOpt::propagateSamplerType(llvm::GenIntrinsicInst& I) - return false; - } - -- VectorType* oldTy = cast(I.getType()); -+ IGCLLVM::FixedVectorType* oldTy = cast(I.getType()); - llvm::SmallVector overloadTys; - auto retTy = IGCLLVM::FixedVectorType::get(newDstType, int_cast(oldTy->getNumElements())); - overloadTys.push_back(retTy); -diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp -index 67535cfcda..3cdd2975f7 100644 ---- a/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp -+++ b/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp -@@ -24,6 +24,7 @@ IN THE SOFTWARE. - - #include "Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.hpp" - #include "Compiler/IGCPassSupport.h" -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "common/LLVMWarningsPush.hpp" - #include "llvm/IR/Function.h" - #include "common/LLVMWarningsPop.hpp" -@@ -130,7 +131,7 @@ static uint64_t getNumElements(Type* type) - { - return arrayType->getNumElements(); - } -- if (VectorType * vectorType = dyn_cast(type)) -+ if (IGCLLVM::FixedVectorType * vectorType = dyn_cast(type)) - { - return vectorType->getNumElements(); - } -diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp -index 2a9d749959..79ed0948c0 100644 ---- a/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp -+++ b/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp -@@ -27,6 +27,7 @@ IN THE SOFTWARE. - #include "Compiler/IGCPassSupport.h" - #include "GenISAIntrinsics/GenIntrinsicInst.h" - -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "common/LLVMWarningsPush.hpp" - #include - #include -@@ -133,7 +134,7 @@ Value* CorrectlyRoundedDivSqrt::emitIEEEDivide(BinaryOperator* I, Value* Op0, Va - } - else - { -- auto vType = dyn_cast(Ty); -+ auto vType = dyn_cast(Ty); - unsigned VecLen = (uint32_t)vType->getNumElements(); - Divide = UndefValue::get(Ty); - for (unsigned i = 0; i < VecLen; i++) -diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp -index 52a9b61355..5ad3ceda43 100644 ---- a/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp -+++ b/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp -@@ -952,7 +952,7 @@ namespace //Anonymous - { - auto ndrangeStructName = "struct.ndrange_t"; - auto module = _deviceExecCall->getModule(); -- auto ndrangeTy = module->getTypeByName(ndrangeStructName); -+ auto ndrangeTy = IGCLLVM::getTypeByName(module, ndrangeStructName); - if (ndrangeTy == nullptr) - { - //create struct type -@@ -1697,7 +1697,7 @@ namespace //Anonymous - // this generates string. Ie for char2 element_type is char and num_elements is 2 - // that is done by callin BaseTypeName on vector element type, this recursive call has only a depth of one since - // there are no compound vectors in OpenCL. -- auto vType = llvm::dyn_cast(type); -+ auto vType = llvm::dyn_cast(type); - return BaseTypeName(type->getContainedType(0), os) << vType->getNumElements(); - } - default: -diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs.cpp -index 6448463d7d..7df7107961 100644 ---- a/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs.cpp -+++ b/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs.cpp -@@ -24,6 +24,7 @@ IN THE SOFTWARE. - - #include "Compiler/Optimizer/OpenCLPasses/KernelArgs.hpp" - #include "AdaptorCommon/ImplicitArgs.hpp" -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "common/LLVMWarningsPush.hpp" - #include - #include -@@ -388,7 +389,7 @@ unsigned int KernelArg::calcAssociatedArgNo(const ImplicitArg& implicitArg, cons - - unsigned int KernelArg::getNumComponents() const - { -- if (VectorType * vecType = dyn_cast(m_arg->getType())) -+ if (IGCLLVM::FixedVectorType * vecType = dyn_cast(m_arg->getType())) - { - // Vector - return int_cast(vecType->getNumElements()); -diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp -index 407748533e..9f375e1cb7 100644 ---- a/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp -+++ b/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp -@@ -739,7 +739,7 @@ Value* OpenCLPrintfResolution::fixupPrintfArg(CallInst& printfCall, Value* arg, - } - - Type* newType = Type::getFloatTy(arg->getContext()); -- if (auto argVT = dyn_cast(arg->getType())) -+ if (auto argVT = dyn_cast(arg->getType())) - { - newType = IGCLLVM::FixedVectorType::get(newType, (unsigned)argVT->getNumElements()); - } -@@ -769,7 +769,7 @@ void OpenCLPrintfResolution::preprocessPrintfArgs(CallInst& printfCall) - IGC::SHADER_PRINTF_TYPE argDataType = getPrintfArgDataType(arg); - arg = fixupPrintfArg(printfCall, arg, argDataType); - uint vecSize = 0; -- if (auto argVType = dyn_cast(argType)) { -+ if (auto argVType = dyn_cast(argType)) { - vecSize = (uint)argVType->getNumElements(); - } - m_argDescriptors.push_back(SPrintfArgDescriptor(argDataType, arg, vecSize)); -diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp -index 03a4583771..0bade5aa7c 100644 ---- a/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp -+++ b/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp -@@ -29,6 +29,7 @@ IN THE SOFTWARE. - #include "Compiler/IGCPassSupport.h" - #include "Compiler/CISACodeGen/GenCodeGenModule.h" - #include "Compiler/CISACodeGen/LowerGEPForPrivMem.hpp" -+#include "llvmWrapper/IR/DerivedTypes.h" - #include "common/LLVMWarningsPush.hpp" - #include "llvm/Transforms/Utils/Local.h" - #include "llvm/IR/DataLayout.h" -@@ -614,7 +615,7 @@ class TransposeHelperPrivateMem : public TransposeHelper - Type* scalarptrTy = PointerType::get(scalarType, pLoad->getPointerAddressSpace()); - IGC_ASSERT(scalarType->getPrimitiveSizeInBits() / 8 == elementSize); - Value* vec = UndefValue::get(pLoad->getType()); -- auto pLoadVT = cast(pLoad->getType()); -+ auto pLoadVT = cast(pLoad->getType()); - for (unsigned i = 0, e = (unsigned)pLoadVT->getNumElements(); i < e; ++i) - { - Value* ptr = IRB.CreateIntToPtr(address, scalarptrTy); -@@ -653,7 +654,7 @@ class TransposeHelperPrivateMem : public TransposeHelper - IGC_ASSERT(scalarType->getPrimitiveSizeInBits() / 8 == elementSize); - Value* vec = pStore->getValueOperand(); - -- unsigned vecNumElts = (unsigned)cast(vec->getType())->getNumElements(); -+ unsigned vecNumElts = (unsigned)cast(vec->getType())->getNumElements(); - for (unsigned i = 0; i < vecNumElts; ++i) - { - Value* ptr = IRB.CreateIntToPtr(address, scalarptrTy); -@@ -717,7 +718,7 @@ bool PrivateMemoryResolution::testTransposedMemory(const Type* pTmpType, const T - } - else if(pTmpType->isVectorTy()) - { -- auto pTmpVType = cast(pTmpType); -+ auto pTmpVType = cast(pTmpType); - tmpAllocaSize *= pTmpVType->getNumElements(); - pTmpType = pTmpType->getContainedType(0); - ok = (nullptr != pTmpType); -@@ -825,6 +826,8 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack) - - // Construct an empty DebugLoc. - IF_DEBUG_INFO(DebugLoc entryDebugLoc); -+ // Assign with the function location if available. -+ IF_DEBUG_INFO_IF(DISubprogram *subprogram = m_currFunction->getSubprogram(), entryDebugLoc = DILocation::get(subprogram->getContext(), subprogram->getLine(), 0, subprogram);); - IF_DEBUG_INFO(entryBuilder.SetCurrentDebugLocation(entryDebugLoc)); - - if (privateOnStack) -diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp -index 1190330abc..bb2932d5da 100644 ---- a/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp -+++ b/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp -@@ -254,7 +254,7 @@ Instruction* ReplaceUnsupportedIntrinsics::insertLoop(Instruction* Loc, Value* L - Value* ReplaceUnsupportedIntrinsics::replicateScalar( - Value* ScalarVal, Type* Ty, Instruction* InsertBefore) - { -- VectorType* VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType* VTy = dyn_cast(Ty); - Type* ETy = VTy ? VTy->getElementType() : Ty; - uint32_t sBits = (unsigned int)ScalarVal->getType()->getPrimitiveSizeInBits(); - uint32_t nBits = (unsigned int)ETy->getPrimitiveSizeInBits(); -@@ -915,7 +915,7 @@ void ReplaceUnsupportedIntrinsics::replaceFunnelShift(IntrinsicInst* I) { - } - - Value* numBits = Builder.getIntN(sizeInBits, sizeInBits); -- if (auto IVT = dyn_cast(I->getType())) { -+ if (auto IVT = dyn_cast(I->getType())) { - numBits = ConstantVector::getSplat(IGCLLVM::getElementCount((uint32_t)IVT->getNumElements()), cast(numBits)); - } - auto shiftModulo = Builder.CreateURem(I->getArgOperand(2), numBits); -diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp -index c9fed6746b..1882a8cc1f 100644 ---- a/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp -+++ b/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp -@@ -291,7 +291,7 @@ static Value* BuildLoadInst(CallInst& CI, unsigned int Offset, Type* DataType) - auto Size = ElemByteSize; - if (DataType->isVectorTy()) - { -- Size *= DataType->getVectorNumElements(); -+ Size *= (unsigned int)cast(DataType)->getNumElements(); - } - unsigned int AlignedOffset = (Offset / ElemByteSize) * ElemByteSize; - unsigned int LoadByteSize = (Offset == AlignedOffset) ? Size : Size * 2; -diff --git a/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp b/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp -index 9a77ec5386..09efed958d 100644 ---- a/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp -+++ b/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp -@@ -341,7 +341,7 @@ bool PreCompiledFuncImport::preProcessDouble() - } - else - { -- uint32_t vectorSize = cast(Inst->getType())->getNumElements(); -+ uint32_t vectorSize = cast(Inst->getType())->getNumElements(); - fsub = llvm::UndefValue::get(Inst->getType()); - - for (uint32_t i = 0; i < vectorSize; ++i) -@@ -967,7 +967,7 @@ void PreCompiledFuncImport::processDivide(BinaryOperator& inst, EmulatedFunction - - Type* argumentType = inst.getOperand(0)->getType(); - -- if (auto argumentVType = dyn_cast(argumentType)) -+ if (auto argumentVType = dyn_cast(argumentType)) - { - numElements = (unsigned)argumentVType->getNumElements(); - } -diff --git a/IGC/Compiler/Optimizer/Scalarizer.cpp b/IGC/Compiler/Optimizer/Scalarizer.cpp -index 09e1cc9858..3882f4140e 100644 ---- a/IGC/Compiler/Optimizer/Scalarizer.cpp -+++ b/IGC/Compiler/Optimizer/Scalarizer.cpp -@@ -419,7 +419,7 @@ void ScalarizeFunction::scalarizeInstruction(BinaryOperator* BI) - { - V_PRINT(scalarizer, "\t\tBinary instruction\n"); - IGC_ASSERT_MESSAGE(BI, "instruction type dynamic cast failed"); -- VectorType* instType = dyn_cast(BI->getType()); -+ IGCLLVM::FixedVectorType* instType = dyn_cast(BI->getType()); - // Only need handling for vector binary ops - if (!instType) return; - -@@ -479,7 +479,7 @@ void ScalarizeFunction::scalarizeInstruction(CmpInst* CI) - { - V_PRINT(scalarizer, "\t\tCompare instruction\n"); - IGC_ASSERT_MESSAGE(CI, "instruction type dynamic cast failed"); -- VectorType* instType = dyn_cast(CI->getType()); -+ IGCLLVM::FixedVectorType* instType = dyn_cast(CI->getType()); - // Only need handling for vector compares - if (!instType) return; - -@@ -527,13 +527,13 @@ void ScalarizeFunction::scalarizeInstruction(CastInst* CI) - { - V_PRINT(scalarizer, "\t\tCast instruction\n"); - IGC_ASSERT_MESSAGE(CI, "instruction type dynamic cast failed"); -- VectorType* instType = dyn_cast(CI->getType()); -+ IGCLLVM::FixedVectorType* instType = dyn_cast(CI->getType()); - - // For BitCast - we only scalarize if src and dst types have same vector length - if (isa(CI)) - { - if (!instType) return recoverNonScalarizableInst(CI); -- VectorType* srcType = dyn_cast(CI->getOperand(0)->getType()); -+ IGCLLVM::FixedVectorType* srcType = dyn_cast(CI->getOperand(0)->getType()); - if (!srcType || (instType->getNumElements() != srcType->getNumElements())) - { - return recoverNonScalarizableInst(CI); -@@ -588,7 +588,7 @@ void ScalarizeFunction::scalarizeInstruction(PHINode* PI) - { - V_PRINT(scalarizer, "\t\tPHI instruction\n"); - IGC_ASSERT_MESSAGE(PI, "instruction type dynamic cast failed"); -- VectorType* instType = dyn_cast(PI->getType()); -+ IGCLLVM::FixedVectorType* instType = dyn_cast(PI->getType()); - // Only need handling for vector PHI - if (!instType) return; - -@@ -699,7 +699,7 @@ void ScalarizeFunction::scalarizeInstruction(SelectInst* SI) - { - V_PRINT(scalarizer, "\t\tSelect instruction\n"); - IGC_ASSERT_MESSAGE(SI, "instruction type dynamic cast failed"); -- VectorType* instType = dyn_cast(SI->getType()); -+ IGCLLVM::FixedVectorType* instType = dyn_cast(SI->getType()); - // Only need handling for vector select - if (!instType) return; - -@@ -781,7 +781,7 @@ void ScalarizeFunction::scalarizeInstruction(ExtractElementInst* EI) - - // Connect the "extracted" value to all its consumers - uint64_t scalarIndex = cast(scalarIndexVal)->getZExtValue(); -- auto valueVType = cast(vectorValue->getType()); -+ auto valueVType = cast(vectorValue->getType()); - if (static_cast(scalarIndex) < (unsigned)valueVType->getNumElements()) - { - IGC_ASSERT_MESSAGE(NULL != operand[static_cast(scalarIndex)], "SCM error"); -@@ -845,7 +845,7 @@ void ScalarizeFunction::scalarizeInstruction(InsertElementInst* II) - if (isa(sourceVectorValue)) - { - // Scalarize the undef value (generate a scalar undef) -- VectorType* inputVectorType = dyn_cast(sourceVectorValue->getType()); -+ IGCLLVM::FixedVectorType* inputVectorType = dyn_cast(sourceVectorValue->getType()); - IGC_ASSERT_MESSAGE(inputVectorType, "expected vector argument"); - - UndefValue* undefVal = UndefValue::get(inputVectorType->getElementType()); -@@ -886,7 +886,7 @@ void ScalarizeFunction::scalarizeInstruction(ShuffleVectorInst* SI) - IGC_ASSERT(nullptr != sourceVector0Value); - Value* sourceVector1Value = SI->getOperand(1); - IGC_ASSERT(nullptr != sourceVector1Value); -- VectorType* const inputType = dyn_cast(sourceVector0Value->getType()); -+ IGCLLVM::FixedVectorType* const inputType = dyn_cast(sourceVector0Value->getType()); - IGC_ASSERT_MESSAGE(nullptr != inputType, "vector input error"); - IGC_ASSERT_MESSAGE(inputType == sourceVector1Value->getType(), "vector input error"); - unsigned sourceVectorWidth = int_cast(inputType->getNumElements()); -@@ -908,7 +908,7 @@ void ScalarizeFunction::scalarizeInstruction(ShuffleVectorInst* SI) - - // Generate array for shuffled scalar values - SmallVectornewVector; -- unsigned width = int_cast(SI->getType()->getNumElements()); -+ unsigned width = int_cast(cast(SI->getType())->getNumElements()); - - // Generate undef value, which may be needed as some scalar elements - UndefValue* undef = UndefValue::get(inputType->getElementType()); -@@ -977,7 +977,7 @@ void ScalarizeFunction::scalarizeInstruction(GetElementPtrInst* GI) - - if (baseValue->getType()->isVectorTy()) - { -- width = int_cast(dyn_cast(baseValue->getType())->getNumElements()); -+ width = int_cast(dyn_cast(baseValue->getType())->getNumElements()); - // Obtain the scalarized operands - obtainScalarizedValues(operand1, NULL, baseValue, GI); - ptrTy = dyn_cast(baseValue->getType())->getElementType(); -@@ -988,7 +988,7 @@ void ScalarizeFunction::scalarizeInstruction(GetElementPtrInst* GI) - } - if (indexValue->getType()->isVectorTy()) - { -- width = int_cast(dyn_cast(indexValue->getType())->getNumElements()); -+ width = int_cast(dyn_cast(indexValue->getType())->getNumElements()); - // Obtain the scalarized operands - obtainScalarizedValues(operand2, NULL, indexValue, GI); - } -@@ -1027,7 +1027,7 @@ void ScalarizeFunction::obtainScalarizedValues(SmallVectorImpl& retValue - { - V_PRINT(scalarizer, "\t\t\tObtaining scalar value... " << *origValue << "\n"); - -- VectorType* origType = dyn_cast(origValue->getType()); -+ IGCLLVM::FixedVectorType* origType = dyn_cast(origValue->getType()); - IGC_ASSERT_MESSAGE(origType, "Value must have a vector type!"); - unsigned width = int_cast(origType->getNumElements()); - -@@ -1186,7 +1186,7 @@ void ScalarizeFunction::obtainVectorValueWhichMightBeScalarizedImpl(Value* vecto - } - - Value* assembledVector = UndefValue::get(vectorVal->getType()); -- unsigned width = int_cast(dyn_cast(vectorVal->getType())->getNumElements()); -+ unsigned width = int_cast(dyn_cast(vectorVal->getType())->getNumElements()); - for (unsigned i = 0; i < width; i++) - { - IGC_ASSERT_MESSAGE(NULL != valueEntry->scalarValues[i], "SCM entry has NULL value"); -@@ -1246,7 +1246,7 @@ void ScalarizeFunction::updateSCMEntryWithValues(ScalarizeFunction::SCMEntry* en - bool matchDbgLoc) - { - IGC_ASSERT_MESSAGE((origValue->getType()->isArrayTy() || origValue->getType()->isVectorTy()), "only Vector values are supported"); -- unsigned width = int_cast(dyn_cast(origValue->getType())->getNumElements()); -+ unsigned width = int_cast(dyn_cast(origValue->getType())->getNumElements()); - - entry->isOriginalVectorRemoved = isOrigValueRemoved; - -@@ -1316,7 +1316,7 @@ void ScalarizeFunction::resolveDeferredInstructions() - Instruction* vectorInst = dyn_cast(current.unresolvedInst); - IGC_ASSERT_MESSAGE(vectorInst, "DRL only handles unresolved instructions"); - -- VectorType* currType = dyn_cast(vectorInst->getType()); -+ IGCLLVM::FixedVectorType* currType = dyn_cast(vectorInst->getType()); - IGC_ASSERT_MESSAGE(currType, "Cannot have DRL of non-vector value"); - unsigned width = int_cast(currType->getNumElements()); - -diff --git a/IGC/Compiler/Optimizer/ValueTracker.cpp b/IGC/Compiler/Optimizer/ValueTracker.cpp -index ac02746e3f..8c0619edcc 100644 ---- a/IGC/Compiler/Optimizer/ValueTracker.cpp -+++ b/IGC/Compiler/Optimizer/ValueTracker.cpp -@@ -178,7 +178,7 @@ Value* ValueTracker::handleExtractElement(ExtractElementInst* E) - { - auto mask = I->getShuffleMask(); - uint shuffleidx = int_cast(mask[(uint)idx]); -- auto vType = dyn_cast(I->getOperand(0)->getType()); -+ auto vType = dyn_cast(I->getOperand(0)->getType()); - baseValue = (shuffleidx < vType->getNumElements()) ? - I->getOperand(0) : I->getOperand(1); - } -diff --git a/IGC/Compiler/VerificationPass.cpp b/IGC/Compiler/VerificationPass.cpp -index 98437d79dd..40d50f5a19 100644 ---- a/IGC/Compiler/VerificationPass.cpp -+++ b/IGC/Compiler/VerificationPass.cpp -@@ -302,7 +302,7 @@ bool VerificationPass::verifyType(Type* type, Value* val) - - case IGCLLVM::VectorTyID: - { -- auto VType = cast(type); -+ auto VType = cast(type); - unsigned typeSize = (unsigned)VType->getNumElements(); - if (!m_IGC_IR_spec.vectorTypeSizes.count(typeSize)) - { -diff --git a/IGC/DebugInfo/DebugInfoUtils.hpp b/IGC/DebugInfo/DebugInfoUtils.hpp -index 7f2e288acd..88b30a75ff 100644 ---- a/IGC/DebugInfo/DebugInfoUtils.hpp -+++ b/IGC/DebugInfo/DebugInfoUtils.hpp -@@ -108,7 +108,7 @@ namespace IGC - IGCLLVM::DIBuilder Builder(M); - llvm::DIGlobalVariable* GV = GVs[j]->getVariable(); - llvm::DIScope* scopeToUse = GV->getScope(); -- llvm::DILocation* locToUse = llvm::DebugLoc::get(GV->getLine(), 0, scopeToUse, loc); -+ llvm::DILocation* locToUse = llvm::DILocation::get(scopeToUse->getContext(), GV->getLine(), 0, scopeToUse, loc); - if (llvm::isa(GV->getScope())) - { - // Function has no DebugLoc so it is either internal -diff --git a/IGC/DebugInfo/DwarfDebug.cpp b/IGC/DebugInfo/DwarfDebug.cpp -index e86ea69a5c..b251531b21 100644 ---- a/IGC/DebugInfo/DwarfDebug.cpp -+++ b/IGC/DebugInfo/DwarfDebug.cpp -@@ -2168,9 +2168,9 @@ static DebugLoc getFnDebugLoc(DebugLoc DL, const LLVMContext& Ctx) - // Check for number of operands since the compatibility is cheap here. - if (SP->getNumOperands() > 19) - { -- return DebugLoc::get(SP->getScopeLine(), 0, SP); -+ return DILocation::get(SP->getContext(), SP->getScopeLine(), 0, SP); - } -- return DebugLoc::get(SP->getLine(), 0, SP); -+ return DILocation::get(SP->getContext(), SP->getLine(), 0, SP); - } - - return DebugLoc(); -diff --git a/IGC/GenISAIntrinsics/GenIntrinsics.cpp b/IGC/GenISAIntrinsics/GenIntrinsics.cpp -index 708cfdaa6a..772155b214 100644 ---- a/IGC/GenISAIntrinsics/GenIntrinsics.cpp -+++ b/IGC/GenISAIntrinsics/GenIntrinsics.cpp -@@ -204,7 +204,7 @@ static Type *DecodeFixedType(ArrayRef &Infos, - case IITDescriptor::SameVecWidthArgument: { - Type *EltTy = DecodeFixedType(Infos, Tys, Context); - Type *Ty = Tys[D.getArgumentNumber()]; -- if (VectorType *VTy = dyn_cast(Ty)) { -+ if (IGCLLVM::FixedVectorType *VTy = dyn_cast(Ty)) { - return IGCLLVM::FixedVectorType::get(EltTy, int_cast(VTy->getNumElements())); - } - IGC_ASSERT_EXIT_MESSAGE(0, "unhandled"); -@@ -215,7 +215,7 @@ static Type *DecodeFixedType(ArrayRef &Infos, - } - case IITDescriptor::VecOfPtrsToElt: { - Type *Ty = Tys[D.getArgumentNumber()]; -- VectorType *VTy = dyn_cast(Ty); -+ IGCLLVM::FixedVectorType *VTy = dyn_cast(Ty); - if (!VTy) - IGC_ASSERT_EXIT_MESSAGE(0, "Expected an argument of Vector Type"); - Type *EltTy = cast(VTy)->getElementType(); -@@ -434,7 +434,7 @@ static std::string getMangledTypeStr(Type* Ty) { - Result += "f"; - } - else if (isa(Ty)) -- Result += "v" + utostr(cast(Ty)->getNumElements()) + -+ Result += "v" + utostr(cast(Ty)->getNumElements()) + - getMangledTypeStr(cast(Ty)->getElementType()); - else if (Ty) - Result += EVT::getEVT(Ty).getEVTString(); -diff --git a/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp b/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp -index af20473ff4..79f74d3301 100644 ---- a/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp -+++ b/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp -@@ -4989,7 +4989,7 @@ void LLVM3DBuilder::VectorToScalars( - IGC_ASSERT(nullptr != vector->getType()); - IGC_ASSERT(vector->getType()->isVectorTy()); - -- const unsigned count = (unsigned)llvm::cast(vector->getType())->getNumElements(); -+ const unsigned count = (unsigned)llvm::cast(vector->getType())->getNumElements(); - IGC_ASSERT(1 < count); - IGC_ASSERT(count <= 4); - IGC_ASSERT(count <= maxSize); -diff --git a/IGC/WrapperLLVM/include/llvmWrapper/IR/DerivedTypes.h b/IGC/WrapperLLVM/include/llvmWrapper/IR/DerivedTypes.h -index 8b67bdf410..307eeaf907 100644 ---- a/IGC/WrapperLLVM/include/llvmWrapper/IR/DerivedTypes.h -+++ b/IGC/WrapperLLVM/include/llvmWrapper/IR/DerivedTypes.h -@@ -27,6 +27,7 @@ IN THE SOFTWARE. - - #include "llvm/Config/llvm-config.h" - #include "llvm/IR/DerivedTypes.h" -+#include "llvm/IR/Module.h" - - namespace IGCLLVM - { -@@ -60,6 +61,15 @@ namespace IGCLLVM - return false; - #endif - } -+ -+ inline llvm::StructType *getTypeByName(llvm::Module *M, llvm::StringRef Name) { -+#if LLVM_VERSION_MAJOR >= 12 -+ return llvm::StructType::getTypeByName(M->getContext(), Name); -+#else -+ return M->getTypeByName(Name); -+#endif -+ } -+ - } - - #endif -diff --git a/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h b/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h -index e8b5621a58..f5abae93c2 100644 ---- a/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h -+++ b/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h -@@ -33,10 +33,14 @@ using namespace llvm; - namespace IGCLLVM { - #if LLVM_VERSION_MAJOR < 11 - inline unsigned getElementCount(unsigned EC) { return EC; } --#else -+#elif LLVM_VERSION_MAJOR == 11 - inline ElementCount getElementCount(unsigned EC) { - return ElementCount(EC, false); - } -+#else -+inline ElementCount getElementCount(unsigned EC) { -+ return ElementCount::get(EC, false); -+} - #endif - } // namespace IGCLLVM - -diff --git a/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Scalar.h b/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Scalar.h -index df56f417bd..97c627347c 100644 ---- a/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Scalar.h -+++ b/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Scalar.h -@@ -42,7 +42,7 @@ namespace IGCLLVM - { - return llvm::createLoopUnrollPass(OptLevel, false, Threshold, Count, AllowPartial, Runtime, UpperBound, AllowPeeling); - } --#elif LLVM_VERSION_MAJOR == 9 || LLVM_VERSION_MAJOR == 10 || LLVM_VERSION_MAJOR == 11 -+#elif LLVM_VERSION_MAJOR >= 9 && LLVM_VERSION_MAJOR <= 12 - inline static llvm::Pass * createLoopUnrollPass( - int OptLevel = 2, int Threshold = -1, int Count = -1, - int AllowPartial = -1, int Runtime = -1, -@@ -50,7 +50,7 @@ namespace IGCLLVM - { - return llvm::createLoopUnrollPass(OptLevel, false, false, Threshold, Count, AllowPartial, Runtime, UpperBound, AllowPeeling); - } --#elif LLVM_VERSION_MAJOR >= 12 -+#else - //DO NOT assume same function signature for all incoming llvm versions! Double check to upgrade! - #error Not supported llvm version. - #endif -diff --git a/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Utils/LoopUtils.h b/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Utils/LoopUtils.h -index 6868b09fbe..78a55949aa 100644 ---- a/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Utils/LoopUtils.h -+++ b/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Utils/LoopUtils.h -@@ -39,6 +39,14 @@ namespace IGCLLVM - return llvm::InsertPreheaderForLoop(L, DT, LI, nullptr, PreserveLCSSA); - } - #endif -+ -+ inline bool isInnermost(llvm::Loop *L) { -+#if LLVM_VERSION_MAJOR >= 12 -+ return L->isInnermost(); -+#else -+ return L->empty(); -+#endif -+ } - } - - #endif -diff --git a/IGC/common/igc_resourceDimTypes.h b/IGC/common/igc_resourceDimTypes.h -index 6831b06c8e..d790330fb8 100644 ---- a/IGC/common/igc_resourceDimTypes.h -+++ b/IGC/common/igc_resourceDimTypes.h -@@ -66,6 +66,11 @@ namespace IGC - resourceDimTypeId == DIM_2D_TYPE || resourceDimTypeId == DIM_2D_ARRAY_TYPE || - resourceDimTypeId == DIM_3D_TYPE || resourceDimTypeId == DIM_CUBE_TYPE || resourceDimTypeId == DIM_CUBE_ARRAY_TYPE)); - -+#if LLVM_VERSION_MAJOR >= 12 -+ llvm::LLVMContext& llvmCtx = module.getContext(); -+ return llvm::StructType::getTypeByName(llvmCtx, ResourceDimensionTypeName[resourceDimTypeId]); -+#else - return module.getTypeByName(ResourceDimensionTypeName[resourceDimTypeId]); -+#endif - } - } -\ No newline at end of file -- 2.44.0