41 #define DEBUG_TYPE "machinelicm"
45 cl::desc(
"MachineLICM should avoid speculation"),
50 cl::desc(
"MachineLICM should hoist even cheap instructions"),
55 cl::desc(
"MachineLICM should sink instructions into "
56 "loops to avoid register spills"),
60 "Number of machine instructions hoisted out of loops");
62 "Number of instructions hoisted in low reg pressure situation");
64 "Number of high latency instructions hoisted");
66 "Number of hoisted machine instructions CSEed");
68 "Number of machine instructions hoisted out of loops post regalloc");
121 unsigned SpeculationState;
130 explicit MachineLICM(
bool PreRA) :
146 void releaseMemory()
override {
156 struct CandidateInfo {
161 :
MI(mi),
Def(def), FI(fi) {}
164 void HoistRegionPostRA();
172 void AddToLiveIns(
unsigned Reg);
198 void ExitScopeIfDone(
213 bool ConsiderUnseenAsDef);
216 bool ConsiderUnseenAsDef =
false);
222 std::vector<const MachineInstr *> &PrevMIs);
226 DenseMap<
unsigned, std::vector<const MachineInstr *>>::iterator &CI);
241 "Machine Loop Invariant Code Motion",
false,
false)
251 if (!CurLoop->getLoopPredecessor())
265 Changed = FirstInLoop =
false;
274 PreRegAlloc =
MRI->isSSA();
277 DEBUG(
dbgs() <<
"******** Pre-regalloc Machine LICM: ");
279 DEBUG(
dbgs() <<
"******** Post-regalloc Machine LICM: ");
284 unsigned NumRPS = TRI->getNumRegPressureSets();
287 RegLimit.resize(NumRPS);
288 for (
unsigned i = 0, e = NumRPS; i != e; ++i)
289 RegLimit[i] = TRI->getRegPressureSetLimit(MF, i);
293 MLI = &getAnalysis<MachineLoopInfo>();
294 DT = &getAnalysis<MachineDominatorTree>();
295 AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
298 while (!Worklist.empty()) {
300 CurPreheader =
nullptr;
306 Worklist.append(CurLoop->begin(), CurLoop->end());
310 CurLoop->getExitBlocks(ExitBlocks);
337 if (!MemOp->isStore() || !MemOp->getPseudoValue())
340 dyn_cast<FixedStackPseudoSourceValue>(MemOp->getPseudoValue())) {
341 if (
Value->getFrameIndex() == FI)
355 bool RuledOut =
false;
356 bool HasNonInvariantUse =
false;
361 int FI = MO.getIndex();
362 if (!StoredFIs.
count(FI) &&
363 MFI->isSpillSlotObjectIndex(FI) &&
366 HasNonInvariantUse =
true;
372 if (MO.isRegMask()) {
379 unsigned Reg = MO.getReg();
383 "Not expecting virtual register!");
386 if (Reg && (PhysRegDefs.
test(Reg) || PhysRegClobbers.
test(Reg)))
389 HasNonInvariantUse =
true;
393 if (MO.isImplicit()) {
395 PhysRegClobbers.
set(*AI);
415 if (PhysRegDefs.
test(*AS))
416 PhysRegClobbers.
set(*AS);
417 PhysRegDefs.
set(*AS);
419 if (PhysRegClobbers.
test(Reg))
427 if (Def && !RuledOut) {
429 if ((!HasNonInvariantUse && IsLICMCandidate(*MI)) ||
431 Candidates.
push_back(CandidateInfo(MI, Def, FI));
437 void MachineLICM::HoistRegionPostRA() {
442 unsigned NumRegs = TRI->getNumRegs();
451 const std::vector<MachineBasicBlock *> &Blocks = CurLoop->getBlocks();
456 if (ML && ML->
getHeader()->isEHPad())
continue;
461 for (
const auto &LI : BB->liveins()) {
463 PhysRegDefs.
set(*AI);
466 SpeculationState = SpeculateUnknown;
468 ProcessMI(&MI, PhysRegDefs, PhysRegClobbers, StoredFIs, Candidates);
474 if (TI != Preheader->
end()) {
478 unsigned Reg = MO.getReg();
494 for (CandidateInfo &Candidate : Candidates) {
495 if (Candidate.FI != INT_MIN &&
496 StoredFIs.
count(Candidate.FI))
499 unsigned Def = Candidate.Def;
500 if (!PhysRegClobbers.
test(Def) && !TermRegs.test(Def)) {
504 if (!MO.isReg() || MO.isDef() || !MO.getReg())
506 unsigned Reg = MO.getReg();
507 if (PhysRegDefs.
test(Reg) ||
508 PhysRegClobbers.
test(Reg)) {
516 HoistPostRA(MI, Candidate.Def);
523 void MachineLICM::AddToLiveIns(
unsigned Reg) {
524 const std::vector<MachineBasicBlock *> &Blocks = CurLoop->getBlocks();
526 if (!BB->isLiveIn(Reg))
530 if (!MO.isReg() || !MO.getReg() || MO.isDef())
continue;
531 if (MO.getReg() == Reg || TRI->isSuperRegister(Reg, MO.getReg()))
540 void MachineLICM::HoistPostRA(
MachineInstr *MI,
unsigned Def) {
564 if (SpeculationState != SpeculateUnknown)
565 return SpeculationState == SpeculateFalse;
567 if (BB != CurLoop->getHeader()) {
570 CurLoop->getExitingBlocks(CurrentLoopExitingBlocks);
572 if (!DT->dominates(BB, CurrentLoopExitingBlock)) {
573 SpeculationState = SpeculateTrue;
578 SpeculationState = SpeculateFalse;
591 BackTrace.pop_back();
600 if (OpenChildren[Node])
604 ExitScope(Node->getBlock());
608 unsigned Left = --OpenChildren[Parent];
611 ExitScope(Parent->getBlock());
633 while (!WorkList.
empty()) {
635 assert(Node &&
"Null dominator tree node?");
645 if (!CurLoop->contains(BB))
649 const std::vector<MachineDomTreeNode*> &Children = Node->
getChildren();
650 unsigned NumChildren = Children.size();
658 OpenChildren[Node] = NumChildren;
662 for (
int i = (
int)NumChildren-1; i >= 0; --i) {
664 ParentMap[Child] = Node;
669 if (Scopes.
size() == 0)
675 InitRegPressure(Preheader);
684 SpeculationState = SpeculateUnknown;
686 MII = MBB->
begin(),
E = MBB->
end(); MII !=
E; ) {
689 if (!Hoist(MI, Preheader))
690 UpdateRegPressure(MI);
695 ExitScopeIfDone(Node, OpenChildren, ParentMap);
702 void MachineLICM::SinkIntoLoop() {
712 if (IsLoopInvariantInst(*
I) && !HasLoopPHIUse(&*
I))
737 B = DT->findNearestCommonDominator(B, MI.
getParent());
743 if (!CanSink || !B || B == Preheader)
771 UpdateRegPressure(&MI,
true);
775 void MachineLICM::UpdateRegPressure(
const MachineInstr *MI,
776 bool ConsiderUnseenAsDef) {
777 auto Cost = calcRegisterCost(MI,
true, ConsiderUnseenAsDef);
778 for (
const auto &RPIdAndCost : Cost) {
779 unsigned Class = RPIdAndCost.first;
780 if (static_cast<int>(
RegPressure[Class]) < -RPIdAndCost.second)
794 MachineLICM::calcRegisterCost(
const MachineInstr *MI,
bool ConsiderSeen,
795 bool ConsiderUnseenAsDef) {
803 unsigned Reg = MO.
getReg();
808 bool isNew = ConsiderSeen ? RegSeen.insert(Reg).second :
false;
817 if (isNew && !isKill && ConsiderUnseenAsDef)
820 else if (!isNew && isKill)
825 const int *
PS = TRI->getRegClassPressureSets(RC);
826 for (; *PS != -1; ++
PS) {
827 if (Cost.
find(*PS) == Cost.
end())
848 if (PSV->isGOT() || PSV->isConstantPool())
858 bool DontMoveAcrossStore =
true;
880 bool MachineLICM::IsLoopInvariantInst(
MachineInstr &I) {
881 if (!IsLICMCandidate(I))
889 unsigned Reg = MO.
getReg();
890 if (Reg == 0)
continue;
893 if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
900 if (!
MRI->isConstantPhysReg(Reg) &&
905 }
else if (!MO.
isDead()) {
908 }
else if (CurLoop->getHeader()->isLiveIn(Reg)) {
919 "Machine instr not mapped for this vreg?!");
923 if (CurLoop->contains(
MRI->getVRegDef(Reg)))
934 bool MachineLICM::HasLoopPHIUse(
const MachineInstr *MI)
const {
937 MI = Work.pop_back_val();
941 unsigned Reg = MO.
getReg();
942 if (!TargetRegisterInfo::isVirtualRegister(Reg))
949 if (CurLoop->contains(&
UseMI))
959 if (
UseMI.isCopy() && CurLoop->contains(&
UseMI))
960 Work.push_back(&
UseMI);
963 }
while (!Work.empty());
969 bool MachineLICM::HasHighOperandLatency(
MachineInstr &MI,
970 unsigned DefIdx,
unsigned Reg)
const {
971 if (
MRI->use_nodbg_empty(Reg))
975 if (
UseMI.isCopyLike())
977 if (!CurLoop->contains(
UseMI.getParent()))
979 for (
unsigned i = 0, e =
UseMI.getNumOperands(); i != e; ++i) {
983 unsigned MOReg = MO.
getReg();
987 if (
TII->hasHighOperandLatency(SchedModel,
MRI, MI, DefIdx,
UseMI, i))
1000 bool MachineLICM::IsCheapInstruction(
MachineInstr &MI)
const {
1004 bool isCheap =
false;
1006 for (
unsigned i = 0, e = MI.
getNumOperands(); NumDefs && i != e; ++i) {
1011 unsigned Reg = DefMO.
getReg();
1012 if (TargetRegisterInfo::isPhysicalRegister(Reg))
1015 if (!
TII->hasLowDefLatency(SchedModel, MI, i))
1027 for (
const auto &RPIdAndCost : Cost) {
1028 if (RPIdAndCost.second <= 0)
1031 unsigned Class = RPIdAndCost.first;
1032 int Limit = RegLimit[
Class];
1039 for (
const auto &
RP : BackTrace)
1040 if (static_cast<int>(
RP[Class]) + RPIdAndCost.second >= Limit)
1050 void MachineLICM::UpdateBackTraceRegPressure(
const MachineInstr *MI) {
1053 auto Cost = calcRegisterCost(MI,
false,
1057 for (
auto &
RP : BackTrace)
1058 for (
const auto &RPIdAndCost : Cost)
1059 RP[RPIdAndCost.first] += RPIdAndCost.second;
1064 bool MachineLICM::IsProfitableToHoist(
MachineInstr &MI) {
1080 bool CheapInstr = IsCheapInstruction(MI);
1081 bool CreatesCopy = HasLoopPHIUse(&MI);
1084 if (CheapInstr && CreatesCopy) {
1085 DEBUG(
dbgs() <<
"Won't hoist cheap instr with loop PHI use: " << MI);
1091 if (
TII->isTriviallyReMaterializable(MI, AA))
1100 unsigned Reg = MO.
getReg();
1101 if (!TargetRegisterInfo::isVirtualRegister(Reg))
1103 if (MO.
isDef() && HasHighOperandLatency(MI, i, Reg)) {
1104 DEBUG(
dbgs() <<
"Hoist High Latency: " << MI);
1116 auto Cost = calcRegisterCost(&MI,
false,
1121 if (!CanCauseHighRegPressure(Cost, CheapInstr)) {
1122 DEBUG(
dbgs() <<
"Hoist non-reg-pressure: " << MI);
1129 DEBUG(
dbgs() <<
"Won't hoist instr with loop PHI use: " << MI);
1137 (!IsGuaranteedToExecute(MI.
getParent()) && !MayCSE(&MI))) {
1138 DEBUG(
dbgs() <<
"Won't speculate: " << MI);
1144 if (!
TII->isTriviallyReMaterializable(MI, AA) &&
1146 DEBUG(
dbgs() <<
"Can't remat / high reg-pressure: " << MI);
1168 unsigned LoadRegIndex;
1174 if (NewOpc == 0)
return nullptr;
1179 unsigned Reg =
MRI->createVirtualRegister(RC);
1182 bool Success =
TII->unfoldMemoryOperand(MF, *MI, Reg,
1187 "unfoldMemoryOperand failed when getOpcodeAfterMemoryUnfold "
1190 "Unfolded a load into multiple instructions!");
1193 MBB->insert(Pos, NewMIs[0]);
1194 MBB->insert(Pos, NewMIs[1]);
1197 if (!IsLoopInvariantInst(*NewMIs[0]) || !IsProfitableToHoist(*NewMIs[0])) {
1198 NewMIs[0]->eraseFromParent();
1199 NewMIs[1]->eraseFromParent();
1204 UpdateRegPressure(NewMIs[1]);
1223 std::vector<const MachineInstr*> &PrevMIs) {
1225 if (
TII->produceSameValue(*MI, *PrevMI, (PreRegAlloc ?
MRI :
nullptr)))
1236 DenseMap<
unsigned, std::vector<const MachineInstr*> >::iterator &CI) {
1242 if (
const MachineInstr *Dup = LookForDuplicate(MI, CI->second)) {
1243 DEBUG(
dbgs() <<
"CSEing " << *MI <<
" with " << *Dup);
1253 !TargetRegisterInfo::isPhysicalRegister(MO.
getReg()) ||
1254 MO.
getReg() == Dup->getOperand(i).getReg()) &&
1255 "Instructions with different phys regs are not identical!");
1258 !TargetRegisterInfo::isPhysicalRegister(MO.
getReg()))
1263 for (
unsigned i = 0, e = Defs.
size(); i != e; ++i) {
1264 unsigned Idx = Defs[i];
1266 unsigned DupReg = Dup->getOperand(Idx).getReg();
1269 if (!
MRI->constrainRegClass(DupReg,
MRI->getRegClass(Reg))) {
1271 for (
unsigned j = 0; j != i; ++j)
1272 MRI->setRegClass(Dup->getOperand(Defs[j]).getReg(), OrigRCs[j]);
1277 for (
unsigned Idx : Defs) {
1279 unsigned DupReg = Dup->getOperand(Idx).getReg();
1280 MRI->replaceRegWith(Reg, DupReg);
1281 MRI->clearKillFlags(DupReg);
1296 CI = CSEMap.
find(Opcode);
1302 return LookForDuplicate(MI, CI->second) !=
nullptr;
1310 if (!IsLoopInvariantInst(*MI) || !IsProfitableToHoist(*MI)) {
1312 MI = ExtractHoistableLoad(MI);
1313 if (!MI)
return false;
1319 dbgs() <<
"Hoisting " << *
MI;
1330 InitCSEMap(Preheader);
1331 FirstInLoop =
false;
1337 CI = CSEMap.
find(Opcode);
1338 if (!EliminateCSE(MI, CI)) {
1348 UpdateBackTraceRegPressure(MI);
1358 if (CI != CSEMap.
end())
1359 CI->second.push_back(MI);
1361 CSEMap[Opcode].push_back(MI);
1376 if (CurPreheader == reinterpret_cast<MachineBasicBlock *>(-1))
1379 if (!CurPreheader) {
1380 CurPreheader = CurLoop->getLoopPreheader();
1381 if (!CurPreheader) {
1389 if (!CurPreheader) {
1395 return CurPreheader;
unsigned succ_size() const
void push_back(const T &Elt)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
instr_iterator instr_begin()
instr_iterator instr_end()
STATISTIC(NumFunctions,"Total number of functions")
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
char & MachineLICMID
MachineLICM - This pass performs LICM on machine instructions.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Describe properties that are true of each instruction in the target description file.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
void setBitsNotInMask(const uint32_t *Mask, unsigned MaskWords=~0u)
setBitsNotInMask - Add a bit to this vector for every '0' bit in Mask.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
LoopT * getParentLoop() const
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
iterator_range< mmo_iterator > memoperands()
bool canFoldAsLoad(QueryType Type=IgnoreBundle) const
Return true for instructions that can be folded as memory operands in other instructions.
iterator_range< mop_iterator > operands()
static bool mayLoadFromGOTOrConstantPool(MachineInstr &MI)
Return true if this machine instruction loads from global offset table or constant pool...
BlockT * getHeader() const
bool isDereferenceableInvariantLoad(AliasAnalysis *AA) const
Return true if this load instruction never traps and points to a memory location whose value doesn't ...
const std::vector< DomTreeNodeBase * > & getChildren() const
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e...
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
A description of a memory reference used in the backend.
Each TargetRegisterClass has a per register weight, and weight limit which must be less than the limi...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Provide an instruction scheduling machine model to CodeGen passes.
const HexagonInstrInfo * TII
static bool isOperandKill(const MachineOperand &MO, MachineRegisterInfo *MRI)
Machine Loop Invariant Code false
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
Reg
All possible values of the reg field in the ModR/M byte.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
const MCSchedModel & getSchedModel() const
Get the machine model for this subtarget's CPU.
static cl::opt< bool > AvoidSpeculation("avoid-speculation", cl::desc("MachineLICM should avoid speculation"), cl::init(true), cl::Hidden)
LLVM_NODISCARD bool empty() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
Base class for the actual dominator tree node.
bool isCopyLike() const
Return true if the instruction behaves like a copy.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
TargetInstrInfo - Interface to description of machine instruction set.
iterator find(const_arg_type_t< KeyT > Val)
bool isImplicitDef() const
initializer< Ty > init(const Ty &Val)
static cl::opt< bool > SinkInstsToAvoidSpills("sink-insts-to-avoid-spills", cl::desc("MachineLICM should sink instructions into ""loops to avoid register spills"), cl::init(false), cl::Hidden)
unsigned const MachineRegisterInfo * MRI
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineInstrBuilder & UseMI
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
const MachineOperand & getOperand(unsigned i) const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
static cl::opt< bool > HoistCheapInsts("hoist-cheap-insts", cl::desc("MachineLICM should hoist even cheap instructions"), cl::init(false), cl::Hidden)
MCRegAliasIterator enumerates all registers aliasing Reg.
Represent the analysis usage information of a pass.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
static bool InstructionStoresToFI(const MachineInstr *MI, int FI)
Return true if instruction stores to the specified frame.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
pred_iterator pred_begin()
void initializeMachineLICMPass(PassRegistry &)
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
bool isSafeToMove(AliasAnalysis *AA, bool &SawStore) const
Return true if it is safe to move this instruction.
bool memoperands_empty() const
Return true if we don't have any memory operands which described the the memory access done by this i...
INITIALIZE_PASS_BEGIN(MachineLICM, DEBUG_TYPE,"Machine Loop Invariant Code Motion", false, false) INITIALIZE_PASS_END(MachineLICM
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool test(unsigned Idx) const
virtual const TargetLowering * getTargetLowering() const
LLVM_NODISCARD T pop_back_val()
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void setDebugLoc(DebugLoc dl)
Replace current source information with new such.
Special value supplied for machine level alias analysis.
Machine Loop Invariant Code static false bool LoopIsOuterMostWithPredecessor(MachineLoop *CurLoop)
Test if the given loop is the outer-most loop that has a unique predecessor.
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
TargetInstrInfo overrides.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
TargetSubtargetInfo - Generic base class for all target subtargets.
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Represents a single loop in the control flow graph.
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug instruction using the specified regis...
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
BlockT * getLoopPredecessor() const
If the given loop's header has exactly one unique predecessor outside the loop, return it...
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Instructions::iterator instr_iterator
unsigned getReg() const
getReg - Returns the register number.
Machine Loop Invariant Code Motion
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P)
Split the critical edge from this block to the given successor block, and return the newly created bl...
virtual const TargetInstrInfo * getInstrInfo() const
LLVM Value Representation.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
static bool isExitBlock(BasicBlock *BB, const SmallVectorImpl< BasicBlock * > &ExitBlocks)
Return true if the specified block is in the list.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
A specialized PseudoSourceValue for holding FixedStack values, which must include a frame index...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
unsigned pred_size() const
This file describes how to lower LLVM code to machine code.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.