[PATCH] D123559: [DA] Refactor with a better API (NFC)

Congzhe Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 18:09:48 PDT 2022


congzhe created this revision.
congzhe added reviewers: Meinersbur, bmahjour, LoopOptWG.
congzhe added projects: LoopOptWG, LLVM.
Herald added a subscriber: hiraditya.
Herald added a project: All.
congzhe requested review of this revision.
Herald added a subscriber: llvm-commits.

Refactor from iteratively using BitCastInst::getOperand() to using stripPointerCasts() instead, NFC.

After this patch, I will update the same piece of code in https://reviews.llvm.org/D122857 correspondingly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123559

Files:
  llvm/lib/Analysis/DependenceAnalysis.cpp


Index: llvm/lib/Analysis/DependenceAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/DependenceAnalysis.cpp
+++ llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -3351,10 +3351,10 @@
 
   Value *SrcBasePtr = SrcGEP->getOperand(0);
   Value *DstBasePtr = DstGEP->getOperand(0);
-  while (auto *PCast = dyn_cast<BitCastInst>(SrcBasePtr))
-    SrcBasePtr = PCast->getOperand(0);
-  while (auto *PCast = dyn_cast<BitCastInst>(DstBasePtr))
-    DstBasePtr = PCast->getOperand(0);
+  if (auto *PCast = dyn_cast<BitCastInst>(SrcBasePtr))
+    SrcBasePtr = PCast->stripPointerCasts();
+  if (auto *PCast = dyn_cast<BitCastInst>(DstBasePtr))
+    DstBasePtr = PCast->stripPointerCasts();
 
   // Check that for identical base pointers we do not miss index offsets
   // that have been added before this GEP is applied.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123559.422086.patch
Type: text/x-patch
Size: 857 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220412/2244a937/attachment.bin>


More information about the llvm-commits mailing list