本文整理汇总了C++中SelectInst::getParent方法的典型用法代码示例。如果您正苦于以下问题:C++ SelectInst::getParent方法的具体用法?C++ SelectInst::getParent怎么用?C++ SelectInst::getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectInst
的用法示例。
在下文中一共展示了SelectInst::getParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CanSelectOperandBeMappingIntoPredBlock
/// CanSelectOperandBeMappingIntoPredBlock - SI is a select whose condition is a
/// PHI node (but the two may be in different blocks). See if the true/false
/// values (V) are live in all of the predecessor blocks of the PHI. For
/// example, cases like this cannot be mapped:
///
/// X = phi [ C1, BB1], [C2, BB2]
/// Y = add
/// Z = select X, Y, 0
///
/// because Y is not live in BB1/BB2.
///
static bool CanSelectOperandBeMappingIntoPredBlock(const Value *V,
const SelectInst &SI) {
// If the value is a non-instruction value like a constant or argument, it
// can always be mapped.
const Instruction *I = dyn_cast<Instruction>(V);
if (!I) return true;
// If V is a PHI node defined in the same block as the condition PHI, we can
// map the arguments.
const PHINode *CondPHI = cast<PHINode>(SI.getCondition());
if (const PHINode *VP = dyn_cast<PHINode>(I))
if (VP->getParent() == CondPHI->getParent())
return true;
// Otherwise, if the PHI and select are defined in the same block and if V is
// defined in a different block, then we can transform it.
if (SI.getParent() == CondPHI->getParent() &&
I->getParent() != CondPHI->getParent())
return true;
// Otherwise we have a 'hard' case and we can't tell without doing more
// detailed dominator based analysis, punt.
return false;
}
示例2: visitSelectInst
bool Scalarizer::visitSelectInst(SelectInst &SI) {
VectorType *VT = dyn_cast<VectorType>(SI.getType());
if (!VT)
return false;
unsigned NumElems = VT->getNumElements();
IRBuilder<> Builder(SI.getParent(), &SI);
Scatterer Op1 = scatter(&SI, SI.getOperand(1));
Scatterer Op2 = scatter(&SI, SI.getOperand(2));
assert(Op1.size() == NumElems && "Mismatched select");
assert(Op2.size() == NumElems && "Mismatched select");
ValueVector Res;
Res.resize(NumElems);
if (SI.getOperand(0)->getType()->isVectorTy()) {
Scatterer Op0 = scatter(&SI, SI.getOperand(0));
assert(Op0.size() == NumElems && "Mismatched select");
for (unsigned I = 0; I < NumElems; ++I)
Res[I] = Builder.CreateSelect(Op0[I], Op1[I], Op2[I],
SI.getName() + ".i" + Twine(I));
} else {
Value *Op0 = SI.getOperand(0);
for (unsigned I = 0; I < NumElems; ++I)
Res[I] = Builder.CreateSelect(Op0, Op1[I], Op2[I],
SI.getName() + ".i" + Twine(I));
}
gather(&SI, Res);
return true;
}
示例3: annotateOneSelectInst
void SelectInstVisitor::annotateOneSelectInst(SelectInst &SI) {
std::vector<uint64_t> &CountFromProfile = UseFunc->getProfileRecord().Counts;
assert(*CurCtrIdx < CountFromProfile.size() &&
"Out of bound access of counters");
uint64_t SCounts[2];
SCounts[0] = CountFromProfile[*CurCtrIdx]; // True count
++(*CurCtrIdx);
uint64_t TotalCount = UseFunc->getBBInfo(SI.getParent()).CountValue;
// False Count
SCounts[1] = (TotalCount > SCounts[0] ? TotalCount - SCounts[0] : 0);
uint64_t MaxCount = std::max(SCounts[0], SCounts[1]);
if (MaxCount)
setProfMetadata(F.getParent(), &SI, SCounts, MaxCount);
}