From 9d10770f15bdc78dfbb36fade06266f10e250d81 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sun, 5 May 2019 20:23:45 +0000 Subject: [PATCH] [TargetLowering] getValueType - use dyn_cast directly to find VectorType. NFCI. Matches what we do in other getValueType functions and fixes a null dereference warning in scan-build. Also cleans up the rest of the function - use auto and standardize the variable names. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360000 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/TargetLowering.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/include/llvm/CodeGen/TargetLowering.h b/include/llvm/CodeGen/TargetLowering.h index ba7989de8ac..1724afcd57e 100644 --- a/include/llvm/CodeGen/TargetLowering.h +++ b/include/llvm/CodeGen/TargetLowering.h @@ -1164,21 +1164,20 @@ public: EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown = false) const { // Lower scalar pointers to native pointer types. - if (PointerType *PTy = dyn_cast(Ty)) + if (auto *PTy = dyn_cast(Ty)) return getPointerTy(DL, PTy->getAddressSpace()); - if (Ty->isVectorTy()) { - VectorType *VTy = cast(Ty); - Type *Elm = VTy->getElementType(); + if (auto *VTy = dyn_cast(Ty)) { + Type *EltTy = VTy->getElementType(); // Lower vectors of pointers to native pointer types. - if (PointerType *PT = dyn_cast(Elm)) { - EVT PointerTy(getPointerTy(DL, PT->getAddressSpace())); - Elm = PointerTy.getTypeForEVT(Ty->getContext()); + if (auto *PTy = dyn_cast(EltTy)) { + EVT PointerTy(getPointerTy(DL, PTy->getAddressSpace())); + EltTy = PointerTy.getTypeForEVT(Ty->getContext()); } - - return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(Elm, false), - VTy->getNumElements()); + return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(EltTy, false), + VTy->getNumElements()); } + return EVT::getEVT(Ty, AllowUnknown); } -- 2.40.0