[llvm] ae58cc0 - IVDescriptors: clarify getSCEV use in a function (NFC) (#106222)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 27 08:44:53 PDT 2024


Author: Ramkumar Ramachandra
Date: 2024-08-27T16:44:50+01:00
New Revision: ae58cc0e9993db13e5256c21ae5e971b2974968f

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

LOG: IVDescriptors: clarify getSCEV use in a function (NFC) (#106222)

getSCEV will assert unless the operand is SCEVable. Replace an instance
of the implementation of ScalarEvolution::isSCEVable (which checks that
the operand is either integer or pointer type) with a call to the
function, to make it clear that the subsequent use of getSCEV will not
fail.

Added: 
    

Modified: 
    llvm/lib/Analysis/IVDescriptors.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp
index ac6df226784345..f5258601fd5d49 100644
--- a/llvm/lib/Analysis/IVDescriptors.cpp
+++ b/llvm/lib/Analysis/IVDescriptors.cpp
@@ -1479,8 +1479,8 @@ bool InductionDescriptor::isInductionPHI(
     InductionDescriptor &D, const SCEV *Expr,
     SmallVectorImpl<Instruction *> *CastsToIgnore) {
   Type *PhiTy = Phi->getType();
-  // We only handle integer and pointer inductions variables.
-  if (!PhiTy->isIntegerTy() && !PhiTy->isPointerTy())
+  // isSCEVable returns true for integer and pointer types.
+  if (!SE->isSCEVable(PhiTy))
     return false;
 
   // Check that the PHI is consecutive.


        


More information about the llvm-commits mailing list