[llvm] [InstCombine] Remove scalable vector extracts to and from the same type (PR #69702)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 20 06:28:52 PDT 2023
================
@@ -2997,24 +2997,26 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
return replaceOperand(CI, 0, InsertTuple);
}
- auto *DstTy = dyn_cast<FixedVectorType>(ReturnType);
- auto *VecTy = dyn_cast<FixedVectorType>(Vec->getType());
+ auto *DstTy = dyn_cast<VectorType>(ReturnType);
+ auto *VecTy = dyn_cast<VectorType>(Vec->getType());
- // Only canonicalize if the destination vector and Vec are fixed
- // vectors.
if (DstTy && VecTy) {
- unsigned DstNumElts = DstTy->getNumElements();
- unsigned VecNumElts = VecTy->getNumElements();
+ auto DstEltCnt = DstTy->getElementCount();
unsigned IdxN = cast<ConstantInt>(Idx)->getZExtValue();
// Extracting the entirety of Vec is a nop.
- if (VecNumElts == DstNumElts) {
+ if (DstEltCnt == VecTy->getElementCount()) {
----------------
david-arm wrote:
nit: Given you have to query the element count for VecTy anyway here you could just save a copy of it, i.e.
`auto VecEltCnt = VecTy->getElementCount();`
and reuse it for the check below so it's consistent with Dst, i.e.
`if (VecEltCnt.isScalable() || DstEltCnt.isScalable())`
https://github.com/llvm/llvm-project/pull/69702
More information about the llvm-commits
mailing list