]> granicus.if.org Git - llvm/commitdiff
[TargetLowering] getValueType - use dyn_cast directly to find VectorType. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 5 May 2019 20:23:45 +0000 (20:23 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 5 May 2019 20:23:45 +0000 (20:23 +0000)
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

index ba7989de8ac23c0585a09b137570d11625f1d6f9..1724afcd57eaff99f60b5a90c94c39d46f32b31d 100644 (file)
@@ -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<PointerType>(Ty))
+    if (auto *PTy = dyn_cast<PointerType>(Ty))
       return getPointerTy(DL, PTy->getAddressSpace());
 
-    if (Ty->isVectorTy()) {
-      VectorType *VTy = cast<VectorType>(Ty);
-      Type *Elm = VTy->getElementType();
+    if (auto *VTy = dyn_cast<VectorType>(Ty)) {
+      Type *EltTy = VTy->getElementType();
       // Lower vectors of pointers to native pointer types.
-      if (PointerType *PT = dyn_cast<PointerType>(Elm)) {
-        EVT PointerTy(getPointerTy(DL, PT->getAddressSpace()));
-        Elm = PointerTy.getTypeForEVT(Ty->getContext());
+      if (auto *PTy = dyn_cast<PointerType>(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);
   }