if (BranchInst *BI = dyn_cast<BranchInst>(&I)) {
// Count a conditional branch as savings if it becomes unconditional.
if (BI->isConditional() &&
- dyn_cast_or_null<ConstantInt>(
+ isa_and_nonnull<ConstantInt>(
SimplifiedValues.lookup(BI->getCondition()))) {
CurrentSavings += InlineConstants::InstrCost;
}
// inliner more regular and predictable. Interestingly, conditional branches
// which will fold away are also free.
return BI.isUnconditional() || isa<ConstantInt>(BI.getCondition()) ||
- dyn_cast_or_null<ConstantInt>(
+ isa_and_nonnull<ConstantInt>(
SimplifiedValues.lookup(BI.getCondition()));
}
// taking conservative care to avoid excessive recursion.
if (Depth < MaxAnalysisRecursionDepth - 1 && !Known.Zero && !Known.One) {
// Skip if every incoming value references to ourself.
- if (dyn_cast_or_null<UndefValue>(P->hasConstantValue()))
+ if (isa_and_nonnull<UndefValue>(P->hasConstantValue()))
break;
Known.Zero.setAllBits();
if (auto *DDI = dyn_cast<DbgDeclareInst>(&I))
if (auto *DIExpr = DDI->getExpression())
if (DIExpr->startsWithDeref() &&
- dyn_cast_or_null<Argument>(DDI->getAddress())) {
+ isa_and_nonnull<Argument>(DDI->getAddress())) {
SmallVector<uint64_t, 8> Ops;
Ops.append(std::next(DIExpr->elements_begin()),
DIExpr->elements_end());
oe = MI.memoperands_end();
o != oe; ++o) {
if ((*o)->isLoad() &&
- dyn_cast_or_null<FixedStackPseudoSourceValue>((*o)->getPseudoValue()))
+ isa_and_nonnull<FixedStackPseudoSourceValue>((*o)->getPseudoValue()))
Accesses.push_back(*o);
}
return Accesses.size() != StartSize;
oe = MI.memoperands_end();
o != oe; ++o) {
if ((*o)->isStore() &&
- dyn_cast_or_null<FixedStackPseudoSourceValue>((*o)->getPseudoValue()))
+ isa_and_nonnull<FixedStackPseudoSourceValue>((*o)->getPseudoValue()))
Accesses.push_back(*o);
}
return Accesses.size() != StartSize;
bool ReplaceableMetadataImpl::isReplaceable(const Metadata &MD) {
if (auto *N = dyn_cast<MDNode>(&MD))
return !N->isResolved();
- return dyn_cast<ValueAsMetadata>(&MD);
+ return isa<ValueAsMetadata>(&MD);
}
static DISubprogram *getLocalFunctionMetadata(Value *V) {
// In the new format type nodes shall have a reference to the parent type as
// its first operand.
- MDNode *Parent = dyn_cast_or_null<MDNode>(Type->getOperand(0));
- if (!Parent)
- return false;
-
- return true;
+ return isa_and_nonnull<MDNode>(Type->getOperand(0));
}
bool TBAAVerifier::visitTBAAMetadata(Instruction &I, const MDNode *MD) {
if (!GEP)
return false;
bool Changed = false;
- if (GEP->hasOneUse() &&
- dyn_cast<GetElementPtrInst>(GEP->getPointerOperand())) {
+ if (GEP->hasOneUse() && isa<GetElementPtrInst>(GEP->getPointerOperand())) {
IRBuilder<> Builder(GEP->getContext());
Builder.SetInsertPoint(GEP);
Builder.SetCurrentDebugLocation(GEP->getDebugLoc());
const GlobalValue *GV = G ? G->getGlobal() : nullptr;
return DAG.getTarget().shouldAssumeDSOLocal(*Mod, GV) &&
- !dyn_cast_or_null<GlobalIFunc>(GV);
+ !isa_and_nonnull<GlobalIFunc>(GV);
};
// The PLT is only used in 32-bit ELF PIC mode. Attempting to use the PLT in
// For f32 we also have legal lowering when the element is loaded from
// memory.
if (VT == MVT::v4f32 || VT == MVT::v2f64) {
- if (!C || (VT == MVT::v4f32 && dyn_cast<LoadSDNode>(V2)))
+ if (!C || (VT == MVT::v4f32 && isa<LoadSDNode>(V2)))
return DAG.getNode(PPCISD::VECINSERT, dl, VT, V1, V2, V3);
return Op;
}
for (DbgVariableIntrinsic *DVI : Worklist) {
if (IsUnreachableBlock(DVI->getParent()))
DVI->eraseFromParent();
- else if (dyn_cast_or_null<AllocaInst>(DVI->getVariableLocationOp(0))) {
+ else if (isa_and_nonnull<AllocaInst>(DVI->getVariableLocationOp(0))) {
// Count all non-debuginfo uses in reachable blocks.
unsigned Uses = 0;
for (auto *User : DVI->getVariableLocationOp(0)->users())
const auto &ED = A.getAAFor<AAExecutionDomain>(
*this, IRPosition::function(*F), DepClassTy::REQUIRED);
if (CallBase *CB = dyn_cast<CallBase>(U))
- if (!dyn_cast<ConstantInt>(CB->getArgOperand(0)) ||
+ if (!isa<ConstantInt>(CB->getArgOperand(0)) ||
!ED.isExecutedByInitialThreadOnly(*CB))
MallocCalls.erase(CB);
}
// See if we know something about the comparison itself, like it is the target
// of an assume.
auto *CmpPI = PredInfo->getPredicateInfoFor(I);
- if (dyn_cast_or_null<PredicateAssume>(CmpPI))
+ if (isa_and_nonnull<PredicateAssume>(CmpPI))
return ExprResult::some(
createConstantExpression(ConstantInt::getTrue(CI->getType())));