[llvm] feb9b37 - [SCEV] Address post-commit comments for #113915.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 17 11:32:17 PST 2024


Author: Florian Hahn
Date: 2024-11-17T19:31:56Z
New Revision: feb9b3701bf6650f91e12e7f4efbe72383f3f60b

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

LOG: [SCEV] Address post-commit comments for #113915.

Address post-commit comments for
https://github.com/llvm/llvm-project/pull/113915.

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/ScalarEvolution.h
    llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index 72044b739c4372..885c5985f9d23a 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -1328,7 +1328,7 @@ class ScalarEvolution {
     /// Collect loop guards in \p Guards, starting from PHINode \p
     /// Phi, by calling \p collectFromBlock on the incoming blocks of
     /// \Phi and trying to merge the found constraints into a single
-    /// combined on for \p Phi.
+    /// combined one for \p Phi.
     static void collectFromPHI(
         ScalarEvolution &SE, ScalarEvolution::LoopGuards &Guards,
         const PHINode &Phi, SmallPtrSetImpl<const BasicBlock *> &VisitedBlocks,

diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 5182285c874dd4..46b108606f6a62 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -15274,17 +15274,17 @@ void ScalarEvolution::LoopGuards::collectFromPHI(
     if (Inserted)
       collectFromBlock(SE, G->second, Phi.getParent(), InBlock, VisitedBlocks,
                        Depth + 1);
-    auto S = G->second.RewriteMap.find(
-        SE.getSCEV(Phi.getIncomingValue(IncomingIdx)));
-    if (S == G->second.RewriteMap.end())
+    auto &RewriteMap = G->second.RewriteMap;
+    if (RewriteMap.empty())
+      return {nullptr, scCouldNotCompute};
+    auto S = RewriteMap.find(SE.getSCEV(Phi.getIncomingValue(IncomingIdx)));
+    if (S == RewriteMap.end())
       return {nullptr, scCouldNotCompute};
     auto *SM = dyn_cast_if_present<SCEVMinMaxExpr>(S->second);
     if (!SM)
       return {nullptr, scCouldNotCompute};
     if (const SCEVConstant *C0 = dyn_cast<SCEVConstant>(SM->getOperand(0)))
       return {C0, SM->getSCEVType()};
-    if (const SCEVConstant *C1 = dyn_cast<SCEVConstant>(SM->getOperand(1)))
-      return {C1, SM->getSCEVType()};
     return {nullptr, scCouldNotCompute};
   };
   auto MergeMinMaxConst = [](MinMaxPattern P1,


        


More information about the llvm-commits mailing list