[PATCH] D102533: [NFC][OpaquePtr] Avoid using PointerType::getElementType() in VectorUtils.cpp

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 14 14:02:44 PDT 2021


aeubanks created this revision.
aeubanks added a reviewer: dblaikie.
Herald added a subscriber: hiraditya.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102533

Files:
  llvm/lib/Analysis/VectorUtils.cpp


Index: llvm/lib/Analysis/VectorUtils.cpp
===================================================================
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -959,12 +959,18 @@
   DFS.perform(LI);
   for (BasicBlock *BB : make_range(DFS.beginRPO(), DFS.endRPO()))
     for (auto &I : *BB) {
-      auto *LI = dyn_cast<LoadInst>(&I);
-      auto *SI = dyn_cast<StoreInst>(&I);
-      if (!LI && !SI)
+      Type *ElementTy;
+      Value *Ptr;
+      if (auto *LI = dyn_cast<LoadInst>(&I)) {
+        ElementTy = LI->getType();
+        Ptr = LI->getPointerOperand();
+      } else if (auto *SI = dyn_cast<StoreInst>(&I)) {
+        ElementTy = SI->getValueOperand()->getType();
+        Ptr = SI->getPointerOperand();
+      } else {
         continue;
+      }
 
-      Value *Ptr = getLoadStorePointerOperand(&I);
       // We don't check wrapping here because we don't know yet if Ptr will be
       // part of a full group or a group with gaps. Checking wrapping for all
       // pointers (even those that end up in groups with no gaps) will be overly
@@ -976,8 +982,7 @@
                                     /*Assume=*/true, /*ShouldCheckWrap=*/false);
 
       const SCEV *Scev = replaceSymbolicStrideSCEV(PSE, Strides, Ptr);
-      PointerType *PtrTy = cast<PointerType>(Ptr->getType());
-      uint64_t Size = DL.getTypeAllocSize(PtrTy->getElementType());
+      uint64_t Size = DL.getTypeAllocSize(ElementTy);
       AccessStrideInfo[&I] = StrideDescriptor(Stride, Scev, Size,
                                               getLoadStoreAlignment(&I));
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102533.345556.patch
Type: text/x-patch
Size: 1598 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210514/2dfb47fa/attachment.bin>


More information about the llvm-commits mailing list