diff polly/lib/Support/ScopHelper.cpp @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 79ff65ed7e25
children 1f2b6ac9f198
line wrap: on
line diff
--- a/polly/lib/Support/ScopHelper.cpp	Wed Jul 21 10:27:27 2021 +0900
+++ b/polly/lib/Support/ScopHelper.cpp	Wed Nov 09 17:45:10 2022 +0900
@@ -27,17 +27,12 @@
 
 #define DEBUG_TYPE "polly-scop-helper"
 
-static cl::opt<bool> PollyAllowErrorBlocks(
-    "polly-allow-error-blocks",
-    cl::desc("Allow to speculate on the execution of 'error blocks'."),
-    cl::Hidden, cl::init(true), cl::ZeroOrMore, cl::cat(PollyCategory));
-
 static cl::list<std::string> DebugFunctions(
     "polly-debug-func",
     cl::desc("Allow calls to the specified functions in SCoPs even if their "
              "side-effects are unknown. This can be used to do debug output in "
              "Polly-transformed code."),
-    cl::Hidden, cl::ZeroOrMore, cl::CommaSeparated, cl::cat(PollyCategory));
+    cl::Hidden, cl::CommaSeparated, cl::cat(PollyCategory));
 
 // Ensures that there is just one predecessor to the entry node from outside the
 // region.
@@ -238,7 +233,7 @@
 /// and we generate code outside/in front of that region. Hence, we generate the
 /// code for the SDiv/SRem operands in front of the analyzed region and then
 /// create a new SDiv/SRem operation there too.
-struct ScopExpander : SCEVVisitor<ScopExpander, const SCEV *> {
+struct ScopExpander final : SCEVVisitor<ScopExpander, const SCEV *> {
   friend struct SCEVVisitor<ScopExpander, const SCEV *>;
 
   explicit ScopExpander(const Region &R, ScalarEvolution &SE,
@@ -396,6 +391,12 @@
       NewOps.push_back(visit(Op));
     return SE.getSMinExpr(NewOps);
   }
+  const SCEV *visitSequentialUMinExpr(const SCEVSequentialUMinExpr *E) {
+    SmallVector<const SCEV *, 4> NewOps;
+    for (const SCEV *Op : E->operands())
+      NewOps.push_back(visit(Op));
+    return SE.getUMinExpr(NewOps, /*Sequential=*/true);
+  }
   const SCEV *visitAddRecExpr(const SCEVAddRecExpr *E) {
     SmallVector<const SCEV *, 4> NewOps;
     for (const SCEV *Op : E->operands())
@@ -413,54 +414,6 @@
   return Expander.expandCodeFor(E, Ty, IP);
 }
 
-bool polly::isErrorBlock(BasicBlock &BB, const Region &R, LoopInfo &LI,
-                         const DominatorTree &DT) {
-  if (!PollyAllowErrorBlocks)
-    return false;
-
-  if (isa<UnreachableInst>(BB.getTerminator()))
-    return true;
-
-  if (LI.isLoopHeader(&BB))
-    return false;
-
-  // Basic blocks that are always executed are not considered error blocks,
-  // as their execution can not be a rare event.
-  bool DominatesAllPredecessors = true;
-  if (R.isTopLevelRegion()) {
-    for (BasicBlock &I : *R.getEntry()->getParent())
-      if (isa<ReturnInst>(I.getTerminator()) && !DT.dominates(&BB, &I))
-        DominatesAllPredecessors = false;
-  } else {
-    for (auto Pred : predecessors(R.getExit()))
-      if (R.contains(Pred) && !DT.dominates(&BB, Pred))
-        DominatesAllPredecessors = false;
-  }
-
-  if (DominatesAllPredecessors)
-    return false;
-
-  for (Instruction &Inst : BB)
-    if (CallInst *CI = dyn_cast<CallInst>(&Inst)) {
-      if (isDebugCall(CI))
-        continue;
-
-      if (isIgnoredIntrinsic(CI))
-        continue;
-
-      // memset, memcpy and memmove are modeled intrinsics.
-      if (isa<MemSetInst>(CI) || isa<MemTransferInst>(CI))
-        continue;
-
-      if (!CI->doesNotAccessMemory())
-        return true;
-      if (CI->doesNotReturn())
-        return true;
-    }
-
-  return false;
-}
-
 Value *polly::getConditionFromTerminator(Instruction *TI) {
   if (BranchInst *BR = dyn_cast<BranchInst>(TI)) {
     if (BR->isUnconditional())
@@ -794,13 +747,13 @@
 }
 
 bool polly::getBooleanLoopAttribute(MDNode *LoopID, StringRef Name) {
-  return getOptionalBoolLoopAttribute(LoopID, Name).getValueOr(false);
+  return getOptionalBoolLoopAttribute(LoopID, Name).value_or(false);
 }
 
 llvm::Optional<int> polly::getOptionalIntLoopAttribute(MDNode *LoopID,
                                                        StringRef Name) {
   const MDOperand *AttrMD =
-      findNamedMetadataArg(LoopID, Name).getValueOr(nullptr);
+      findNamedMetadataArg(LoopID, Name).value_or(nullptr);
   if (!AttrMD)
     return None;