Skip to content

Commit 47d71b6

Browse files
authored
[BasicTTI] Only split vectors with even element counts in getCastInstrCost (#166528)
Fixes #166320
1 parent fd9dd43 commit 47d71b6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,8 +1331,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
13311331
bool SplitDst =
13321332
TLI->getTypeAction(Dst->getContext(), TLI->getValueType(DL, Dst)) ==
13331333
TargetLowering::TypeSplitVector;
1334-
if ((SplitSrc || SplitDst) && SrcVTy->getElementCount().isVector() &&
1335-
DstVTy->getElementCount().isVector()) {
1334+
if ((SplitSrc || SplitDst) && SrcVTy->getElementCount().isKnownEven() &&
1335+
DstVTy->getElementCount().isKnownEven()) {
13361336
Type *SplitDstTy = VectorType::getHalfElementsVectorType(DstVTy);
13371337
Type *SplitSrcTy = VectorType::getHalfElementsVectorType(SrcVTy);
13381338
const T *TTI = thisT();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: opt -passes=vector-combine %s -S -o - | FileCheck %s
2+
3+
target triple = "aarch64-unknown-linux-gnu"
4+
5+
define <vscale x 4 x i16> @interleave2_same_const_splat_nxv4i16() {
6+
;CHECK-LABEL: @interleave2_same_const_splat_nxv4i16(
7+
;CHECK: call <vscale x 4 x i16> @llvm.vector.interleave2
8+
;CHECK: ret <vscale x 4 x i16> %retval
9+
%retval = call <vscale x 4 x i16> @llvm.vector.interleave2.nxv4i16(<vscale x 2 x i16> splat(i16 3), <vscale x 2 x i16> splat(i16 3))
10+
ret <vscale x 4 x i16> %retval
11+
}

0 commit comments

Comments
 (0)