[llvm] [llvm] prefer isa_and_nonnull over v && isa (PR #95327)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 15:55:23 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Mohammed Keyvanzadeh (VoltrexKeyva)
<details>
<summary>Changes</summary>
Use `isa_and_nonnull<T>(v)` instead of `v && isa<T>(v)`, where `v` is evaluated twice in the latter.
---
Full diff: https://github.com/llvm/llvm-project/pull/95327.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/ConstantFolding.cpp (+2-2)
``````````diff
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index e0f5bf0ab8365..46a7f832f6761 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -82,7 +82,7 @@ static Constant *foldConstVectorToAPInt(APInt &Result, Type *DestTy,
else
Element = C->getAggregateElement(i);
- if (Element && isa<UndefValue>(Element)) {
+ if (isa_and_nonnull<UndefValue>(Element)) {
Result <<= BitShift;
continue;
}
@@ -218,7 +218,7 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) {
unsigned ShiftAmt = isLittleEndian ? 0 : SrcBitSize*(Ratio-1);
for (unsigned j = 0; j != Ratio; ++j) {
Constant *Src = C->getAggregateElement(SrcElt++);
- if (Src && isa<UndefValue>(Src))
+ if (isa_and_nonnull<UndefValue>(Src))
Src = Constant::getNullValue(
cast<VectorType>(C->getType())->getElementType());
else
``````````
</details>
https://github.com/llvm/llvm-project/pull/95327
More information about the llvm-commits
mailing list