LLVM  6.0.0svn
Namespaces | Macros | Functions | Variables
HexagonLoopIdiomRecognition.cpp File Reference
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpander.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/Local.h"
#include <algorithm>
#include <array>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces

 llvm
 Compute iterated dominance frontiers using a linear time algorithm.
 

Macros

#define DEBUG_TYPE   "hexagon-lir"
 

Functions

void llvm::initializeHexagonLoopIdiomRecognizePass (PassRegistry &)
 
Passllvm::createHexagonLoopIdiomPass ()
 
 INITIALIZE_PASS_BEGIN (HexagonLoopIdiomRecognize, "hexagon-loop-idiom", "Recognize Hexagon-specific loop idioms", false, false) INITIALIZE_PASS_END(HexagonLoopIdiomRecognize
 
static void replaceAllUsesOfWithIn (Value *I, Value *J, BasicBlock *BB)
 
static bool hasZeroSignBit (const Value *V)
 
static bool mayLoopAccessLocation (Value *Ptr, ModRefInfo Access, Loop *L, const SCEV *BECount, unsigned StoreSize, AliasAnalysis &AA, SmallPtrSetImpl< Instruction *> &Ignored)
 mayLoopAccessLocation - Return true if the specified loop might access the specified pointer location, which is a loop-strided access. More...
 

Variables

static cl::opt< boolDisableMemcpyIdiom ("disable-memcpy-idiom", cl::Hidden, cl::init(false), cl::desc("Disable generation of memcpy in loop idiom recognition"))
 
static cl::opt< boolDisableMemmoveIdiom ("disable-memmove-idiom", cl::Hidden, cl::init(false), cl::desc("Disable generation of memmove in loop idiom recognition"))
 
static cl::opt< unsignedRuntimeMemSizeThreshold ("runtime-mem-idiom-threshold", cl::Hidden, cl::init(0), cl::desc("Threshold (in bytes) for the runtime " "check guarding the memmove."))
 
static cl::opt< unsignedCompileTimeMemSizeThreshold ("compile-time-mem-idiom-threshold", cl::Hidden, cl::init(64), cl::desc("Threshold (in bytes) to perform the transformation, if the " "runtime loop count (mem transfer size) is known at compile-time."))
 
static cl::opt< boolOnlyNonNestedMemmove ("only-nonnested-memmove-idiom", cl::Hidden, cl::init(true), cl::desc("Only enable generating memmove in non-nested loops"))
 
cl::opt< boolHexagonVolatileMemcpy ("disable-hexagon-volatile-memcpy", cl::Hidden, cl::init(false), cl::desc("Enable Hexagon-specific memcpy for volatile destination."))
 
static cl::opt< unsignedSimplifyLimit ("hlir-simplify-limit", cl::init(10000), cl::Hidden, cl::desc("Maximum number of simplification steps in HLIR"))
 
static const charHexagonVolatileMemcpyName = "hexagon_memcpy_forward_vp4cp4n2"
 
hexagon loop idiom
 
hexagon loop Recognize Hexagon specific loop idioms
 
hexagon loop Recognize Hexagon specific loop false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "hexagon-lir"

Definition at line 10 of file HexagonLoopIdiomRecognition.cpp.

Function Documentation

◆ hasZeroSignBit()

static bool hasZeroSignBit ( const Value V)
static

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( HexagonLoopIdiomRecognize  ,
"hexagon-loop-idiom ,
"Recognize Hexagon-specific loop idioms ,
false  ,
false   
)

◆ mayLoopAccessLocation()

static bool mayLoopAccessLocation ( Value Ptr,
ModRefInfo  Access,
Loop L,
const SCEV BECount,
unsigned  StoreSize,
AliasAnalysis AA,
SmallPtrSetImpl< Instruction *> &  Ignored 
)
static

mayLoopAccessLocation - Return true if the specified loop might access the specified pointer location, which is a loop-strided access.

The 'Access' argument specifies what the verboten forms of access are (read or write).

Definition at line 1909 of file HexagonLoopIdiomRecognition.cpp.

References llvm::LoopBase< BlockT, LoopT >::addBasicBlockToLoop(), llvm::all_of(), assert(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::LoopBase< BlockT, LoopT >::blocks(), llvm::SCEVExpander::clear(), llvm::SmallVectorImpl< T >::clear(), CompileTimeMemSizeThreshold, llvm::SmallSet< T, N, C >::count(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::BasicBlock::Create(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateBr(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateCondBr(), llvm::IRBuilder< T, Inserter >::CreateICmpSLE(), llvm::IRBuilder< T, Inserter >::CreateICmpULT(), llvm::IRBuilderBase::CreateMemCpy(), llvm::IRBuilderBase::CreateMemMove(), llvm::IRBuilder< T, Inserter >::CreateOr(), llvm::IRBuilder< T, Inserter >::CreatePtrToInt(), llvm::IRBuilder< T, Inserter >::CreateSub(), llvm::dbgs(), DEBUG, DisableMemcpyIdiom, DisableMemmoveIdiom, llvm::dyn_cast(), E, llvm::SmallVectorTemplateCommon< T >::end(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::Instruction::eraseFromParent(), llvm::SCEVExpander::expandCodeFor(), llvm::GlobalValue::ExternalLinkage, llvm::SCEV::FlagNUW, llvm::ConstantInt::get(), llvm::LoadInst::getAlignment(), llvm::StoreInst::getAlignment(), llvm::PHINode::getBasicBlockIndex(), llvm::LoopBase< BlockT, LoopT >::getBlocks(), llvm::Value::getContext(), llvm::Module::getDataLayout(), llvm::Instruction::getDebugLoc(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::Type::getInt32PtrTy(), llvm::Type::getInt32Ty(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::IRBuilderBase::getIntPtrTy(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::AAResults::getModRefInfo(), llvm::BasicBlock::getModule(), llvm::Value::getName(), llvm::Module::getOrInsertFunction(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::LoopBase< BlockT, LoopT >::getParentLoop(), llvm::LoadInst::getPointerAddressSpace(), llvm::StoreInst::getPointerAddressSpace(), llvm::LoadInst::getPointerOperand(), llvm::StoreInst::getPointerOperand(), llvm::Module::getTargetTriple(), llvm::BasicBlock::getTerminator(), llvm::SCEV::getType(), llvm::Value::getType(), llvm::Loop::getUniqueExitBlocks(), llvm::StoreInst::getValueOperand(), llvm::Type::getVoidTy(), llvm::Function::hasFnAttribute(), llvm::Triple::hexagon, HexagonVolatileMemcpy, HexagonVolatileMemcpyName, I, llvm::tgtok::In, llvm::SmallSet< T, N, C >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), Int32Ty, llvm::intersectModRef(), llvm::isModOrRefSet(), llvm::StoreInst::isSimple(), llvm::StoreInst::isVolatile(), llvm::Mod, llvm::ModRef, OnlyNonNestedMemmove, llvm::User::op_begin(), llvm::User::op_end(), llvm::pred_begin(), llvm::pred_end(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::RecursivelyDeleteTriviallyDeadInstructions(), RuntimeMemSizeThreshold, llvm::Instruction::setDebugLoc(), llvm::DomTreeNodeBase< NodeT >::setIDom(), llvm::PHINode::setIncomingBlock(), llvm::IRBuilderBase::SetInsertPoint(), llvm::GlobalValue::setLinkage(), llvm::Value::setName(), llvm::SimplifyInstruction(), llvm::SmallVectorTemplateCommon< T >::size(), Threshold, llvm::MemoryLocation::UnknownSize, and llvm::Value::users().

◆ replaceAllUsesOfWithIn()

static void replaceAllUsesOfWithIn ( Value I,
Value J,
BasicBlock BB 
)
static

Definition at line 655 of file HexagonLoopIdiomRecognition.cpp.

References llvm::MCID::Add, llvm::AArch64CC::AL, assert(), B, llvm::BasicBlock::begin(), C, llvm::computeKnownBits(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateIntCast(), llvm::IRBuilder< T, Inserter >::CreateTrunc(), llvm::IRBuilder< T, Inserter >::CreateXor(), llvm::dyn_cast(), E, llvm::WebAssembly::End, llvm::BasicBlock::end(), F(), llvm::ConstantInt::get(), llvm::IntegerType::getBitWidth(), llvm::SelectInst::getCondition(), llvm::Intrinsic::getDeclaration(), llvm::SelectInst::getFalseValue(), llvm::BasicBlock::getFirstInsertionPt(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::APInt::getLowBitsSet(), llvm::PHINode::getNumIncomingValues(), llvm::User::getNumOperands(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), getParent(), llvm::BasicBlock::getSinglePredecessor(), llvm::BasicBlock::getTerminator(), llvm::SelectInst::getTrueValue(), llvm::Value::getType(), llvm::Use::getUser(), H, llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, if(), llvm::tgtok::In, llvm::Type::isIntegerTy(), llvm::Instruction::isTerminator(), isZero(), llvm_unreachable, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::Value::mutateType(), N, llvm::User::operands(), P, llvm::RecursivelyDeleteTriviallyDeadInstructions(), llvm::Value::replaceAllUsesWith(), llvm::User::replaceUsesOfWith(), llvm::MCID::Select, llvm::User::setOperand(), llvm::SimplifyInstruction(), T, llvm::transform(), llvm::Value::user_begin(), llvm::Value::user_end(), Users, llvm::Value::users(), llvm::RISCVFenceField::W, X, Y, and llvm::Z.

Variable Documentation

◆ CompileTimeMemSizeThreshold

cl::opt<unsigned> CompileTimeMemSizeThreshold("compile-time-mem-idiom-threshold", cl::Hidden, cl::init(64), cl::desc("Threshold (in bytes) to perform the transformation, if the " "runtime loop count (mem transfer size) is known at compile-time."))
static

Referenced by mayLoopAccessLocation().

◆ DisableMemcpyIdiom

cl::opt<bool> DisableMemcpyIdiom("disable-memcpy-idiom", cl::Hidden, cl::init(false), cl::desc("Disable generation of memcpy in loop idiom recognition"))
static

Referenced by mayLoopAccessLocation().

◆ DisableMemmoveIdiom

cl::opt<bool> DisableMemmoveIdiom("disable-memmove-idiom", cl::Hidden, cl::init(false), cl::desc("Disable generation of memmove in loop idiom recognition"))
static

Referenced by mayLoopAccessLocation().

◆ false

hexagon loop Recognize Hexagon specific loop false

Definition at line 265 of file HexagonLoopIdiomRecognition.cpp.

◆ HexagonVolatileMemcpy

cl::opt<bool> HexagonVolatileMemcpy("disable-hexagon-volatile-memcpy", cl::Hidden, cl::init(false), cl::desc("Enable Hexagon-specific memcpy for volatile destination."))

◆ HexagonVolatileMemcpyName

const char* HexagonVolatileMemcpyName = "hexagon_memcpy_forward_vp4cp4n2"
static

Definition at line 104 of file HexagonLoopIdiomRecognition.cpp.

Referenced by mayLoopAccessLocation().

◆ idiom

hexagon loop idiom

Definition at line 265 of file HexagonLoopIdiomRecognition.cpp.

◆ idioms

hexagon loop Recognize Hexagon specific loop idioms

Definition at line 265 of file HexagonLoopIdiomRecognition.cpp.

◆ OnlyNonNestedMemmove

cl::opt<bool> OnlyNonNestedMemmove("only-nonnested-memmove-idiom", cl::Hidden, cl::init(true), cl::desc("Only enable generating memmove in non-nested loops"))
static

Referenced by mayLoopAccessLocation().

◆ RuntimeMemSizeThreshold

cl::opt<unsigned> RuntimeMemSizeThreshold("runtime-mem-idiom-threshold", cl::Hidden, cl::init(0), cl::desc("Threshold (in bytes) for the runtime " "check guarding the memmove."))
static

Referenced by mayLoopAccessLocation().

◆ SimplifyLimit

cl::opt<unsigned> SimplifyLimit("hlir-simplify-limit", cl::init(10000), cl::Hidden, cl::desc("Maximum number of simplification steps in HLIR"))
static