[llvm] 0af3ab0 - [NFC] LoopAccess: Move expressions close to usage

Aditya Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 23 07:09:07 PDT 2022


Author: Aditya Kumar
Date: 2022-08-23T07:08:42-07:00
New Revision: 0af3ab02fd8320ef72a1599ad57b2cfae4b7f2a8

URL: https://github.com/llvm/llvm-project/commit/0af3ab02fd8320ef72a1599ad57b2cfae4b7f2a8
DIFF: https://github.com/llvm/llvm-project/commit/0af3ab02fd8320ef72a1599ad57b2cfae4b7f2a8.diff

LOG: [NFC] LoopAccess: Move expressions close to usage

Avoids useless evaluation of these expressions.

Reviewed By: michaelmaitland, fhahn

Differential Revision: https://reviews.llvm.org/D132337

Added: 
    

Modified: 
    llvm/lib/Analysis/LoopAccessAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 52d2316fe0501..a9a4a820db50a 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -286,8 +286,6 @@ void RuntimePointerChecking::tryToCreateDiffCheck(
     return;
   }
 
-  const DataLayout &DL =
-      SinkAR->getLoop()->getHeader()->getModule()->getDataLayout();
   SmallVector<Instruction *, 4> SrcInsts =
       DC.getInstructionsForAccess(Src->PointerValue, Src->IsWritePtr);
   SmallVector<Instruction *, 4> SinkInsts =
@@ -298,11 +296,10 @@ void RuntimePointerChecking::tryToCreateDiffCheck(
     CanUseDiffCheck = false;
     return;
   }
+  const DataLayout &DL =
+      SinkAR->getLoop()->getHeader()->getModule()->getDataLayout();
   unsigned AllocSize =
       std::max(DL.getTypeAllocSize(SrcTy), DL.getTypeAllocSize(DstTy));
-  IntegerType *IntTy =
-      IntegerType::get(Src->PointerValue->getContext(),
-                       DL.getPointerSizeInBits(CGI.AddressSpace));
 
   // Only matching constant steps matching the AllocSize are supported at the
   // moment. This simplifies the 
diff erence computation. Can be extended in the
@@ -314,6 +311,10 @@ void RuntimePointerChecking::tryToCreateDiffCheck(
     return;
   }
 
+  IntegerType *IntTy =
+      IntegerType::get(Src->PointerValue->getContext(),
+                       DL.getPointerSizeInBits(CGI.AddressSpace));
+
   // When counting down, the dependence distance needs to be swapped.
   if (Step->getValue()->isNegative())
     std::swap(SinkAR, SrcAR);


        


More information about the llvm-commits mailing list