[llvm] [NFC] Add assertions for Src and Dst vec types in VecCombine folding (PR #134432)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 4 11:51:49 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-vectorizers
Author: None (calebwat)
<details>
<summary>Changes</summary>
SrcVecTy and DstVecTy are used without a null check, and originate from a dyn_cast. This patch adds an assertion that these values are non-null before they are used/dereferenced.
---
Full diff: https://github.com/llvm/llvm-project/pull/134432.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/VectorCombine.cpp (+3)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 4bfe41a5ed00d..fc04266cac51b 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -2052,6 +2052,9 @@ bool VectorCombine::foldShuffleOfSelects(Instruction &I) {
auto *SrcVecTy = dyn_cast<FixedVectorType>(T1->getType());
auto *DstVecTy = dyn_cast<FixedVectorType>(I.getType());
+ assert(SrcVecTy && DstVecTy &&
+ "Expected shuffle/select vector types to be defined");
+
auto SK = TargetTransformInfo::SK_PermuteTwoSrc;
auto SelOp = Instruction::Select;
InstructionCost OldCost = TTI.getCmpSelInstrCost(
``````````
</details>
https://github.com/llvm/llvm-project/pull/134432
More information about the llvm-commits
mailing list