Skip to content

Commit 721b796

Browse files
authored
[llvm] prefer isa_and_nonnull over v && isa (#112541)
Use `isa_and_nonnull<T>(v)` instead of `v && isa<T>(v)`, where `v` is evaluated twice in the latter.
1 parent a99bf0f commit 721b796

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static Constant *foldConstVectorToAPInt(APInt &Result, Type *DestTy,
8282
else
8383
Element = C->getAggregateElement(i);
8484

85-
if (Element && isa<UndefValue>(Element)) {
85+
if (isa_and_nonnull<UndefValue>(Element)) {
8686
Result <<= BitShift;
8787
continue;
8888
}
@@ -219,7 +219,7 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) {
219219
unsigned ShiftAmt = isLittleEndian ? 0 : SrcBitSize*(Ratio-1);
220220
for (unsigned j = 0; j != Ratio; ++j) {
221221
Constant *Src = C->getAggregateElement(SrcElt++);
222-
if (Src && isa<UndefValue>(Src))
222+
if (isa_and_nonnull<UndefValue>(Src))
223223
Src = Constant::getNullValue(
224224
cast<VectorType>(C->getType())->getElementType());
225225
else

0 commit comments

Comments
 (0)