本文整理汇总了C++中SelectInst::getOperand方法的典型用法代码示例。如果您正苦于以下问题:C++ SelectInst::getOperand方法的具体用法?C++ SelectInst::getOperand怎么用?C++ SelectInst::getOperand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectInst
的用法示例。
在下文中一共展示了SelectInst::getOperand方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
bool AMDGPUCodeGenPrepare::promoteUniformOpToI32(SelectInst &I) const {
assert(needsPromotionToI32(I.getType()) &&
"I does not need promotion to i32");
IRBuilder<> Builder(&I);
Builder.SetCurrentDebugLocation(I.getDebugLoc());
Type *I32Ty = getI32Ty(Builder, I.getType());
Value *ExtOp1 = nullptr;
Value *ExtOp2 = nullptr;
Value *ExtRes = nullptr;
Value *TruncRes = nullptr;
if (isSigned(I)) {
ExtOp1 = Builder.CreateSExt(I.getOperand(1), I32Ty);
ExtOp2 = Builder.CreateSExt(I.getOperand(2), I32Ty);
} else {
ExtOp1 = Builder.CreateZExt(I.getOperand(1), I32Ty);
ExtOp2 = Builder.CreateZExt(I.getOperand(2), I32Ty);
}
ExtRes = Builder.CreateSelect(I.getOperand(0), ExtOp1, ExtOp2);
TruncRes = Builder.CreateTrunc(ExtRes, I.getType());
I.replaceAllUsesWith(TruncRes);
I.eraseFromParent();
return true;
}
示例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: visitSelectInst
void Interpreter::visitSelectInst(SelectInst &I) {
ExecutionContext &SF = ECStack.back();
GenericValue Src1 = getOperandValue(I.getOperand(0), SF);
GenericValue Src2 = getOperandValue(I.getOperand(1), SF);
GenericValue Src3 = getOperandValue(I.getOperand(2), SF);
GenericValue R = executeSelectInst(Src1, Src2, Src3);
SetValue(&I, R, SF);
}
示例4: handleSelectInstruction
// -- handle select instruction --
void UnsafeTypeCastingCheck::handleSelectInstruction (Instruction *inst) {
SelectInst *sinst = dyn_cast<SelectInst>(inst);
if (sinst == NULL)
utccAbort("handleSelectInstruction cannot process with a non-select instruction");
assert(sinst->getNumOperands() == 3);
Value *choice0 = sinst->getOperand(1);
Value *choice1 = sinst->getOperand(2);
Type *type0 = choice0->getType();
Type *type1 = choice1->getType();
UTCC_TYPE ut0 = llvmT2utccT(type0, choice0);
UTCC_TYPE ut1 = llvmT2utccT(type1, choice1);
if (type0->isIntegerTy() &&
type1->isIntegerTy()) {
if (ut0 == ut1)
setExprType(sinst, ut0);
else if (ut0 == INT_UT || ut1 == INT_UT)
setExprType(sinst, INT_UT);
else setExprType(sinst, NINT_UT);
}
else if (type0->isFloatingPointTy() &&
type1->isFloatingPointTy()) {
if (ut0 == ut1)
setExprType(sinst, ut0);
else if (ut0 == FP_UT || ut1 == FP_UT)
setExprType(sinst, FP_UT);
else setExprType(sinst, NFP_UT);
}
else {
setExprType(sinst, llvmT2utccT(sinst->getType(), sinst));
}
}
示例5: visitSelectInst
void GraphBuilder::visitSelectInst(SelectInst &SI) {
if (!isa<PointerType>(SI.getType()))
return; // Only pointer Selects
DSNodeHandle &Dest = G.getNodeForValue(&SI);
DSNodeHandle S1 = getValueDest(SI.getOperand(1));
DSNodeHandle S2 = getValueDest(SI.getOperand(2));
Dest.mergeWith(S1);
Dest.mergeWith(S2);
}
示例6: SimplifyDivRemOfSelect
/// SimplifyDivRemOfSelect - Try to fold a divide or remainder of a select
/// instruction.
bool InstCombiner::SimplifyDivRemOfSelect(BinaryOperator &I) {
SelectInst *SI = cast<SelectInst>(I.getOperand(1));
// div/rem X, (Cond ? 0 : Y) -> div/rem X, Y
int NonNullOperand = -1;
if (Constant *ST = dyn_cast<Constant>(SI->getOperand(1)))
if (ST->isNullValue())
NonNullOperand = 2;
// div/rem X, (Cond ? Y : 0) -> div/rem X, Y
if (Constant *ST = dyn_cast<Constant>(SI->getOperand(2)))
if (ST->isNullValue())
NonNullOperand = 1;
if (NonNullOperand == -1)
return false;
Value *SelectCond = SI->getOperand(0);
// Change the div/rem to use 'Y' instead of the select.
I.setOperand(1, SI->getOperand(NonNullOperand));
// Okay, we know we replace the operand of the div/rem with 'Y' with no
// problem. However, the select, or the condition of the select may have
// multiple uses. Based on our knowledge that the operand must be non-zero,
// propagate the known value for the select into other uses of it, and
// propagate a known value of the condition into its other users.
// If the select and condition only have a single use, don't bother with this,
// early exit.
if (SI->use_empty() && SelectCond->hasOneUse())
return true;
// Scan the current block backward, looking for other uses of SI.
BasicBlock::iterator BBI = &I, BBFront = I.getParent()->begin();
while (BBI != BBFront) {
--BBI;
// If we found a call to a function, we can't assume it will return, so
// information from below it cannot be propagated above it.
if (isa<CallInst>(BBI) && !isa<IntrinsicInst>(BBI))
break;
// Replace uses of the select or its condition with the known values.
for (Instruction::op_iterator I = BBI->op_begin(), E = BBI->op_end();
I != E; ++I) {
if (*I == SI) {
*I = SI->getOperand(NonNullOperand);
Worklist.Add(BBI);
} else if (*I == SelectCond) {
*I = NonNullOperand == 1 ? ConstantInt::getTrue(BBI->getContext()) :
ConstantInt::getFalse(BBI->getContext());
Worklist.Add(BBI);
}
}
// If we past the instruction, quit looking for it.
if (&*BBI == SI)
SI = 0;
if (&*BBI == SelectCond)
SelectCond = 0;
// If we ran out of things to eliminate, break out of the loop.
if (SelectCond == 0 && SI == 0)
break;
}
return true;
}
示例7: isSigned
bool AMDGPUCodeGenPrepare::isSigned(const SelectInst &I) const {
return isa<ICmpInst>(I.getOperand(0)) ?
cast<ICmpInst>(I.getOperand(0))->isSigned() : false;
}