Skip to content

Commit 0904d15

Browse files
committed
fixup! Add more test cases
1 parent 5130f96 commit 0904d15

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3166,7 +3166,11 @@ bool VectorCombine::foldInterleaveIntrinsics(Instruction &I) {
31663166
auto *ExtVTy = VectorType::getExtendedElementVectorType(VTy);
31673167
unsigned Width = VTy->getElementType()->getIntegerBitWidth();
31683168

3169-
if (TTI.getInstructionCost(&I, CostKind) <
3169+
// Just in case the cost of interleave2 intrinsic and bitcast are both
3170+
// invalid, in which case we want to bail out, we use <= rather
3171+
// than < here. Even they both have valid and equal costs, it's probably
3172+
// not a good idea to emit a high-cost constant splat.
3173+
if (TTI.getInstructionCost(&I, CostKind) <=
31703174
TTI.getCastInstrCost(Instruction::BitCast, I.getType(), ExtVTy,
31713175
TTI::CastContextHint::None, CostKind)) {
31723176
LLVM_DEBUG(dbgs() << "VC: The cost to cast from " << *ExtVTy << " to "
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S -mtriple=riscv64 -mattr=+v,+m,+zvfh %s -passes=vector-combine | FileCheck %s
3+
; RUN: opt -S -mtriple=riscv32 -mattr=+v,+m,+zvfh %s -passes=vector-combine | FileCheck %s
4+
5+
define void @interleave2_const_splat_nxv8i64(ptr %dst) {
6+
; CHECK-LABEL: define void @interleave2_const_splat_nxv8i64(
7+
; CHECK-SAME: ptr [[DST:%.*]]) #[[ATTR0:[0-9]+]] {
8+
; CHECK-NEXT: [[INTERLEAVE2:%.*]] = call <vscale x 8 x i64> @llvm.vector.interleave2.nxv8i64(<vscale x 4 x i64> splat (i64 666), <vscale x 4 x i64> splat (i64 777))
9+
; CHECK-NEXT: call void @llvm.vp.store.nxv8i64.p0(<vscale x 8 x i64> [[INTERLEAVE2]], ptr [[DST]], <vscale x 8 x i1> splat (i1 true), i32 88)
10+
; CHECK-NEXT: ret void
11+
;
12+
%interleave2 = call <vscale x 8 x i64> @llvm.vector.interleave2.nxv8i64(<vscale x 4 x i64> splat (i64 666), <vscale x 4 x i64> splat (i64 777))
13+
call void @llvm.vp.store.nxv8i64.p0(<vscale x 8 x i64> %interleave2, ptr %dst, <vscale x 8 x i1> splat (i1 true), i32 88)
14+
ret void
15+
}

llvm/test/Transforms/VectorCombine/RISCV/vector-interleave2-splat.ll

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
22
; RUN: opt -S -mtriple=riscv64 -mattr=+v,+m,+zvfh %s -passes=vector-combine | FileCheck %s
33
; RUN: opt -S -mtriple=riscv32 -mattr=+v,+m,+zvfh %s -passes=vector-combine | FileCheck %s
4+
; RUN: opt -S -mtriple=riscv64 -mattr=+m,+zve32x %s -passes=vector-combine | FileCheck %s --check-prefix=ZVE32X
45

5-
define void @store_factor2_const_splat(ptr %dst) {
6-
; CHECK-LABEL: define void @store_factor2_const_splat(
6+
define void @interleave2_const_splat_nxv16i32(ptr %dst) {
7+
; CHECK-LABEL: define void @interleave2_const_splat_nxv16i32(
78
; CHECK-SAME: ptr [[DST:%.*]]) #[[ATTR0:[0-9]+]] {
89
; CHECK-NEXT: call void @llvm.vp.store.nxv16i32.p0(<vscale x 16 x i32> bitcast (<vscale x 8 x i64> splat (i64 3337189589658) to <vscale x 16 x i32>), ptr [[DST]], <vscale x 16 x i1> splat (i1 true), i32 88)
910
; CHECK-NEXT: ret void
11+
;
12+
; ZVE32X-LABEL: define void @interleave2_const_splat_nxv16i32(
13+
; ZVE32X-SAME: ptr [[DST:%.*]]) #[[ATTR0:[0-9]+]] {
14+
; ZVE32X-NEXT: [[INTERLEAVE2:%.*]] = call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> splat (i32 666), <vscale x 8 x i32> splat (i32 777))
15+
; ZVE32X-NEXT: call void @llvm.vp.store.nxv16i32.p0(<vscale x 16 x i32> [[INTERLEAVE2]], ptr [[DST]], <vscale x 16 x i1> splat (i1 true), i32 88)
16+
; ZVE32X-NEXT: ret void
1017
;
1118
%interleave2 = call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> splat (i32 666), <vscale x 8 x i32> splat (i32 777))
1219
call void @llvm.vp.store.nxv16i32.p0(<vscale x 16 x i32> %interleave2, ptr %dst, <vscale x 16 x i1> splat (i1 true), i32 88)

0 commit comments

Comments
 (0)