[llvm] 5820c92 - [SCEVExpander] Use early continue and move comment (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 07:58:17 PDT 2023


Author: Nikita Popov
Date: 2023-08-11T16:56:02+02:00
New Revision: 5820c9257e38fbfc15c314b50e629616800a0f95

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

LOG: [SCEVExpander] Use early continue and move comment (NFC)

In preparation for adding additional checks here.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 20844271b943ef..f41aa47c7c9b83 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -1470,20 +1470,21 @@ Value *SCEVExpander::FindValueInExprValueMap(const SCEV *S,
   if (isa<SCEVConstant>(S))
     return nullptr;
 
-  // Choose a Value from the set which dominates the InsertPt.
-  // InsertPt should be inside the Value's parent loop so as not to break
-  // the LCSSA form.
   for (Value *V : SE.getSCEVValues(S)) {
     Instruction *EntInst = dyn_cast<Instruction>(V);
     if (!EntInst)
       continue;
 
+    // Choose a Value from the set which dominates the InsertPt.
+    // InsertPt should be inside the Value's parent loop so as not to break
+    // the LCSSA form.
     assert(EntInst->getFunction() == InsertPt->getFunction());
-    if (S->getType() == V->getType() &&
-        SE.DT.dominates(EntInst, InsertPt) &&
-        (SE.LI.getLoopFor(EntInst->getParent()) == nullptr ||
-         SE.LI.getLoopFor(EntInst->getParent())->contains(InsertPt)))
-      return V;
+    if (S->getType() != V->getType() || !SE.DT.dominates(EntInst, InsertPt) ||
+        !(SE.LI.getLoopFor(EntInst->getParent()) == nullptr ||
+          SE.LI.getLoopFor(EntInst->getParent())->contains(InsertPt)))
+      continue;
+
+    return V;
   }
   return nullptr;
 }


        


More information about the llvm-commits mailing list