LLVM 20.0.0git
|
#include "llvm/Transforms/Scalar/LoopFlatten.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopNestAnalysis.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/LoopVersioning.h"
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
#include "llvm/Transforms/Utils/SimplifyIndVar.h"
#include <optional>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "loop-flatten" |
Variables | |
static cl::opt< unsigned > | RepeatedInstructionThreshold ("loop-flatten-cost-threshold", cl::Hidden, cl::init(2), cl::desc("Limit on the cost of instructions that can be repeated due to " "loop flattening")) |
static cl::opt< bool > | AssumeNoOverflow ("loop-flatten-assume-no-overflow", cl::Hidden, cl::init(false), cl::desc("Assume that the product of the two iteration " "trip counts will never overflow")) |
static cl::opt< bool > | WidenIV ("loop-flatten-widen-iv", cl::Hidden, cl::init(true), cl::desc("Widen the loop induction variables, if possible, so " "overflow checks won't reject flattening")) |
static cl::opt< bool > | VersionLoops ("loop-flatten-version-loops", cl::Hidden, cl::init(true), cl::desc("Version loops if flattened loop could overflow")) |
#define DEBUG_TYPE "loop-flatten" |
Definition at line 81 of file LoopFlatten.cpp.
|
static |
Definition at line 701 of file LoopFlatten.cpp.
References checkIVUsers(), checkOuterLoopInsts(), checkPHIs(), llvm::dbgs(), findLoopComponents(), and LLVM_DEBUG.
Referenced by CanWidenIV(), and FlattenLoopPair().
|
static |
Definition at line 838 of file LoopFlatten.cpp.
References assert(), CanFlattenLoopPair(), llvm::createWideIV(), llvm::dbgs(), Deleted, DL, llvm::Value::dump(), LLVM_DEBUG, llvm::WideIVInfo::NarrowIV, llvm::RecursivelyDeleteDeadPHINode(), Rewriter, and WidenIV.
Referenced by FlattenLoopPair().
|
static |
Definition at line 620 of file LoopFlatten.cpp.
References llvm::dbgs(), and LLVM_DEBUG.
Referenced by CanFlattenLoopPair().
|
static |
Definition at line 553 of file LoopFlatten.cpp.
References B, llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), llvm::TargetTransformInfo::getInstructionCost(), llvm::BranchInst::getSuccessor(), I, llvm::isSafeToSpeculativelyExecute(), llvm::BranchInst::isUnconditional(), LLVM_DEBUG, llvm::PatternMatch::m_c_Mul(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), RepeatedInstructionThreshold, and llvm::TargetTransformInfo::TCK_SizeAndLatency.
Referenced by CanFlattenLoopPair().
|
static |
Definition at line 644 of file LoopFlatten.cpp.
References AssumeNoOverflow, llvm::computeOverflowForUnsignedMul(), llvm::dbgs(), DL, F, GEP, llvm::isGuaranteedToExecuteForEveryIteration(), and LLVM_DEBUG.
Referenced by FlattenLoopPair().
|
static |
Definition at line 468 of file LoopFlatten.cpp.
References assert(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), llvm::Value::dump(), llvm::PHINode::getIncomingValueForBlock(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::PHINode::hasConstantValue(), llvm::SmallPtrSetImpl< PtrType >::insert(), and LLVM_DEBUG.
Referenced by CanFlattenLoopPair().
|
static |
Definition at line 747 of file LoopFlatten.cpp.
References llvm::sampleprof::Base, llvm::BranchInst::Create(), llvm::IRBuilderBase::CreateGEP(), llvm::IRBuilderBase::CreateTrunc(), llvm::dbgs(), DEBUG_TYPE, llvm::DominatorTreeBase< NodeT, IsPostDom >::deleteEdge(), llvm::DominatorTree::dominates(), llvm::Value::dump(), llvm::OptimizationRemarkEmitter::emit(), llvm::LoopInfo::erase(), F, llvm::ScalarEvolution::forgetBlockAndLoopDispositions(), llvm::ScalarEvolution::forgetLoop(), GEP, llvm::IRBuilderBase::GetInsertPoint(), llvm::BasicBlock::getTerminator(), LLVM_DEBUG, PHI, llvm::Remark, llvm::MemorySSAUpdater::removeEdge(), llvm::Instruction::setDebugLoc(), and llvm::IRBuilderBase::SetInsertPoint().
Referenced by FlattenLoopPair().
|
static |
Definition at line 388 of file LoopFlatten.cpp.
References llvm::dbgs(), llvm::Value::dump(), llvm::PHINode::getIncomingValueForBlock(), llvm::Instruction::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_ULT, llvm::SmallPtrSetImpl< PtrType >::insert(), LLVM_DEBUG, RHS, and verifyTripCount().
Referenced by CanFlattenLoopPair().
|
static |
Definition at line 904 of file LoopFlatten.cpp.
References assert(), CanFlattenLoopPair(), CanWidenIV(), checkOverflow(), llvm::IRBuilderBase::CreateCall(), llvm::IRBuilderBase::CreateExtractValue(), llvm::dbgs(), DL, DoFlattenLoopPair(), F, llvm::BranchInst::getCondition(), llvm::Intrinsic::getDeclaration(), llvm::BasicBlock::getTerminator(), llvm::BranchInst::isConditional(), LLVM_DEBUG, llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::BranchInst::setCondition(), llvm::LoopVersioning::versionLoop(), and VersionLoops.
Referenced by llvm::LoopFlattenPass::run().
|
static |
Definition at line 305 of file LoopFlatten.cpp.
References llvm::dbgs(), llvm::Value::dump(), llvm::SmallPtrSetImpl< PtrType >::insert(), and LLVM_DEBUG.
Referenced by verifyTripCount().
STATISTIC | ( | NumFlattened | , |
"Number of loops flattened" | |||
) |
|
static |
Definition at line 321 of file LoopFlatten.cpp.
References llvm::dbgs(), llvm::ScalarEvolution::getBackedgeTakenCount(), llvm::Value::getContext(), llvm::ScalarEvolution::getSCEV(), llvm::ScalarEvolution::getTripCountFromExitCount(), llvm::SCEV::getType(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::ScalarEvolution::getZeroExtendExpr(), LLVM_DEBUG, RHS, and setLoopComponents().
Referenced by findLoopComponents().
|
static |
Referenced by checkOverflow().
|
static |
Referenced by checkOuterLoopInsts().
|
static |
Referenced by FlattenLoopPair().
|
static |
Definition at line 1227 of file SimplifyIndVar.cpp.
Referenced by CanWidenIV(), and llvm::createWideIV().