[llvm] [RISCV] Model interleave2 and deinterleave2 costs with Zvzip (PR #225752)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 22:24:42 PDT 2026


https://github.com/renndong updated https://github.com/llvm/llvm-project/pull/225752

>From 04cb7cf36565adcb135d496901564d3ae3c8a2a2 Mon Sep 17 00:00:00 2001
From: Mingliang Liu <liumingliang.dev at bytedance.com>
Date: Wed, 23 Sep 2026 17:10:00 +0800
Subject: [PATCH 1/3] [RISCV] Precommit the test

---
 .../CostModel/RISCV/shuffle-interleave.ll     | 501 +++++++++++++++++-
 1 file changed, 497 insertions(+), 4 deletions(-)

diff --git a/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll b/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll
index 27c33dca5048af..c988e45b0f08e7 100644
--- a/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll
+++ b/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+v | FileCheck --check-prefixes=CHECK,RV32 %s
 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v | FileCheck --check-prefixes=CHECK,RV64 %s
+; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+v,+zvfh,+experimental-zvzip  | FileCheck --check-prefixes=CHECK,ZVZIP %s
+; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+zve32f,+zvfh,+zvl128b,+experimental-zvzip | FileCheck --check-prefixes=CHECK,ZVE32 %s
 
 ; The mask here interleaves (%v1, %v0), not (%v0, %v1): it should still be cheap.
 define <4 x i8> @interleave2_v2i8(<2 x i8> %v0, <2 x i8> %v1) {
@@ -26,10 +28,25 @@ define <8 x i8> @interleave2_v8i8(<4 x i8> %v0, <4 x i8> %v1) {
 }
 
 define <8 x i32> @interleave2_v8i32(<4 x i32> %v0, <4 x i32> %v1) {
-; CHECK-LABEL: 'interleave2_v8i32'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %concat = shufflevector <4 x i32> %v0, <4 x i32> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = shufflevector <8 x i32> %concat, <8 x i32> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
+; RV32-LABEL: 'interleave2_v8i32'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %concat = shufflevector <4 x i32> %v0, <4 x i32> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; RV32-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = shufflevector <8 x i32> %concat, <8 x i32> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
+;
+; RV64-LABEL: 'interleave2_v8i32'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %concat = shufflevector <4 x i32> %v0, <4 x i32> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; RV64-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = shufflevector <8 x i32> %concat, <8 x i32> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_v8i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %concat = shufflevector <4 x i32> %v0, <4 x i32> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = shufflevector <8 x i32> %concat, <8 x i32> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_v8i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %concat = shufflevector <4 x i32> %v0, <4 x i32> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = shufflevector <8 x i32> %concat, <8 x i32> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
 ;
   %concat = shufflevector <4 x i32> %v0, <4 x i32> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
   %res = shufflevector <8 x i32> %concat, <8 x i32> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
@@ -47,6 +64,16 @@ define <8 x i64> @interleave2_v8i64(<4 x i64> %v0, <4 x i64> %v1) {
 ; RV64-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %concat = shufflevector <4 x i64> %v0, <4 x i64> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
 ; RV64-NEXT:  Cost Model: Found an estimated cost of 22 for instruction: %res = shufflevector <8 x i64> %concat, <8 x i64> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
 ; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i64> %res
+;
+; ZVZIP-LABEL: 'interleave2_v8i64'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %concat = shufflevector <4 x i64> %v0, <4 x i64> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = shufflevector <8 x i64> %concat, <8 x i64> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i64> %res
+;
+; ZVE32-LABEL: 'interleave2_v8i64'
+; ZVE32-NEXT:  Cost Model: Invalid cost for instruction: %concat = shufflevector <4 x i64> %v0, <4 x i64> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %res = shufflevector <8 x i64> %concat, <8 x i64> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i64> %res
 ;
   %concat = shufflevector <4 x i64> %v0, <4 x i64> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
   %res = shufflevector <8 x i64> %concat, <8 x i64> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
@@ -98,3 +125,469 @@ define {<8 x i32>, <8 x i32>} @deinterleave_2_m2_dest(<16 x i32> %v) {
   %res1 = insertvalue {<8 x i32>, <8 x i32>} %res0, <8 x i32> %v1, 1
   ret {<8 x i32>, <8 x i32>} %res1
 }
+
+; Fixed-length interleave2 intrinsics.
+; TODO: we not support the cost calculation of Zvzip in getShuffleCost yet, so
+; the cost of fixed vector may seems weird.
+
+define <2 x i32> @interleave2_intrinsic_v2i32(<1 x i32> %a, <1 x i32> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_v2i32'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call <2 x i32> @llvm.vector.interleave2.v2i32(<1 x i32> %a, <1 x i32> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %res
+;
+  %res = call <2 x i32> @llvm.vector.interleave2.v2i32(<1 x i32> %a, <1 x i32> %b)
+  ret <2 x i32> %res
+}
+
+define <2 x i64> @interleave2_intrinsic_v2i64(<1 x i64> %a, <1 x i64> %b) {
+; RV32-LABEL: 'interleave2_intrinsic_v2i64'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %res = call <2 x i64> @llvm.vector.interleave2.v2i64(<1 x i64> %a, <1 x i64> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_v2i64'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call <2 x i64> @llvm.vector.interleave2.v2i64(<1 x i64> %a, <1 x i64> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_v2i64'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %res = call <2 x i64> @llvm.vector.interleave2.v2i64(<1 x i64> %a, <1 x i64> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_v2i64'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call <2 x i64> @llvm.vector.interleave2.v2i64(<1 x i64> %a, <1 x i64> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %res
+;
+  %res = call <2 x i64> @llvm.vector.interleave2.v2i64(<1 x i64> %a, <1 x i64> %b)
+  ret <2 x i64> %res
+}
+
+define <4 x i1> @interleave2_intrinsic_v4i1(<2 x i1> %a, <2 x i1> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_v4i1'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 28 for instruction: %res = call <4 x i1> @llvm.vector.interleave2.v4i1(<2 x i1> %a, <2 x i1> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i1> %res
+;
+  %res = call <4 x i1> @llvm.vector.interleave2.v4i1(<2 x i1> %a, <2 x i1> %b)
+  ret <4 x i1> %res
+}
+
+define <4 x i8> @interleave2_intrinsic_v4i8(<2 x i8> %a, <2 x i8> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_v4i8'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 18 for instruction: %res = call <4 x i8> @llvm.vector.interleave2.v4i8(<2 x i8> %a, <2 x i8> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i8> %res
+;
+  %res = call <4 x i8> @llvm.vector.interleave2.v4i8(<2 x i8> %a, <2 x i8> %b)
+  ret <4 x i8> %res
+}
+
+define <4 x i32> @interleave2_intrinsic_v4i32(<2 x i32> %a, <2 x i32> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_v4i32'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 18 for instruction: %res = call <4 x i32> @llvm.vector.interleave2.v4i32(<2 x i32> %a, <2 x i32> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %res
+;
+  %res = call <4 x i32> @llvm.vector.interleave2.v4i32(<2 x i32> %a, <2 x i32> %b)
+  ret <4 x i32> %res
+}
+
+define <4 x i64> @interleave2_intrinsic_v4i64(<2 x i64> %a, <2 x i64> %b) {
+; RV32-LABEL: 'interleave2_intrinsic_v4i64'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 57 for instruction: %res = call <4 x i64> @llvm.vector.interleave2.v4i64(<2 x i64> %a, <2 x i64> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_v4i64'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 21 for instruction: %res = call <4 x i64> @llvm.vector.interleave2.v4i64(<2 x i64> %a, <2 x i64> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_v4i64'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 57 for instruction: %res = call <4 x i64> @llvm.vector.interleave2.v4i64(<2 x i64> %a, <2 x i64> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_v4i64'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call <4 x i64> @llvm.vector.interleave2.v4i64(<2 x i64> %a, <2 x i64> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %res
+;
+  %res = call <4 x i64> @llvm.vector.interleave2.v4i64(<2 x i64> %a, <2 x i64> %b)
+  ret <4 x i64> %res
+}
+
+define <8 x i16> @interleave2_intrinsic_v8i16(<4 x i16> %a, <4 x i16> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_v8i16'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 38 for instruction: %res = call <8 x i16> @llvm.vector.interleave2.v8i16(<4 x i16> %a, <4 x i16> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %res
+;
+  %res = call <8 x i16> @llvm.vector.interleave2.v8i16(<4 x i16> %a, <4 x i16> %b)
+  ret <8 x i16> %res
+}
+
+define <8 x i32> @interleave2_intrinsic_v8i32(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_v8i32'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 45 for instruction: %res = call <8 x i32> @llvm.vector.interleave2.v8i32(<4 x i32> %a, <4 x i32> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
+;
+  %res = call <8 x i32> @llvm.vector.interleave2.v8i32(<4 x i32> %a, <4 x i32> %b)
+  ret <8 x i32> %res
+}
+
+define <8 x i32> @interleave2_intrinsic_v8i32_poison(<4 x i32> %a) {
+; CHECK-LABEL: 'interleave2_intrinsic_v8i32_poison'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 34 for instruction: %res = call <8 x i32> @llvm.vector.interleave2.v8i32(<4 x i32> %a, <4 x i32> poison)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
+;
+  %res = call <8 x i32> @llvm.vector.interleave2.v8i32(<4 x i32> %a, <4 x i32> poison)
+  ret <8 x i32> %res
+}
+
+define <16 x i32> @interleave2_intrinsic_v16i32(<8 x i32> %a, <8 x i32> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_v16i32'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 93 for instruction: %res = call <16 x i32> @llvm.vector.interleave2.v16i32(<8 x i32> %a, <8 x i32> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i32> %res
+;
+  %res = call <16 x i32> @llvm.vector.interleave2.v16i32(<8 x i32> %a, <8 x i32> %b)
+  ret <16 x i32> %res
+}
+
+define <32 x i32> @interleave2_intrinsic_v32i32(<16 x i32> %a, <16 x i32> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_v32i32'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 189 for instruction: %res = call <32 x i32> @llvm.vector.interleave2.v32i32(<16 x i32> %a, <16 x i32> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i32> %res
+;
+  %res = call <32 x i32> @llvm.vector.interleave2.v32i32(<16 x i32> %a, <16 x i32> %b)
+  ret <32 x i32> %res
+}
+
+; Scalable interleave2 intrinsics.
+
+define <vscale x 2 x i32> @interleave2_intrinsic_nxv2i32(<vscale x 1 x i32> %a, <vscale x 1 x i32> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv2i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 2 x i32> @llvm.vector.interleave2.nxv2i32(<vscale x 1 x i32> %a, <vscale x 1 x i32> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i32> %res
+;
+  %res = call <vscale x 2 x i32> @llvm.vector.interleave2.nxv2i32(<vscale x 1 x i32> %a, <vscale x 1 x i32> %b)
+  ret <vscale x 2 x i32> %res
+}
+
+define <vscale x 2 x i64> @interleave2_intrinsic_nxv2i64(<vscale x 1 x i64> %a, <vscale x 1 x i64> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv2i64'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 2 x i64> @llvm.vector.interleave2.nxv2i64(<vscale x 1 x i64> %a, <vscale x 1 x i64> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i64> %res
+;
+  %res = call <vscale x 2 x i64> @llvm.vector.interleave2.nxv2i64(<vscale x 1 x i64> %a, <vscale x 1 x i64> %b)
+  ret <vscale x 2 x i64> %res
+}
+
+define <vscale x 4 x i32> @interleave2_intrinsic_nxv4i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv4i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 4 x i32> @llvm.vector.interleave2.nxv4i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x i32> %res
+;
+  %res = call <vscale x 4 x i32> @llvm.vector.interleave2.nxv4i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b)
+  ret <vscale x 4 x i32> %res
+}
+
+define <vscale x 4 x double> @interleave2_intrinsic_nxv4f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv4f64'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 4 x double> @llvm.vector.interleave2.nxv4f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x double> %res
+;
+  %res = call <vscale x 4 x double> @llvm.vector.interleave2.nxv4f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b)
+  ret <vscale x 4 x double> %res
+}
+
+define <vscale x 8 x half> @interleave2_intrinsic_nxv8f16(<vscale x 4 x half> %a, <vscale x 4 x half> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv8f16'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x half> @llvm.vector.interleave2.nxv8f16(<vscale x 4 x half> %a, <vscale x 4 x half> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x half> %res
+;
+  %res = call <vscale x 8 x half> @llvm.vector.interleave2.nxv8f16(<vscale x 4 x half> %a, <vscale x 4 x half> %b)
+  ret <vscale x 8 x half> %res
+}
+
+define <vscale x 8 x i32> @interleave2_intrinsic_nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv8i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x i32> %res
+;
+  %res = call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
+  ret <vscale x 8 x i32> %res
+}
+
+define <vscale x 8 x i32> @interleave2_intrinsic_nxv8i32_poison(<vscale x 4 x i32> %a) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv8i32_poison'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> poison)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x i32> %res
+;
+  %res = call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> poison)
+  ret <vscale x 8 x i32> %res
+}
+
+define <vscale x 8 x float> @interleave2_intrinsic_nxv8f32(<vscale x 4 x float> %a, <vscale x 4 x float> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv8f32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x float> @llvm.vector.interleave2.nxv8f32(<vscale x 4 x float> %a, <vscale x 4 x float> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x float> %res
+;
+  %res = call <vscale x 8 x float> @llvm.vector.interleave2.nxv8f32(<vscale x 4 x float> %a, <vscale x 4 x float> %b)
+  ret <vscale x 8 x float> %res
+}
+
+define <vscale x 16 x i32> @interleave2_intrinsic_nxv16i32(<vscale x 8 x i32> %a, <vscale x 8 x i32> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv16i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> %a, <vscale x 8 x i32> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i32> %res
+;
+  %res = call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> %a, <vscale x 8 x i32> %b)
+  ret <vscale x 16 x i32> %res
+}
+
+define <vscale x 16 x i64> @interleave2_intrinsic_nxv16i64(<vscale x 8 x i64> %a, <vscale x 8 x i64> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv16i64'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 16 x i64> @llvm.vector.interleave2.nxv16i64(<vscale x 8 x i64> %a, <vscale x 8 x i64> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i64> %res
+;
+  %res = call <vscale x 16 x i64> @llvm.vector.interleave2.nxv16i64(<vscale x 8 x i64> %a, <vscale x 8 x i64> %b)
+  ret <vscale x 16 x i64> %res
+}
+
+define <vscale x 32 x i32> @interleave2_intrinsic_nxv32i32(<vscale x 16 x i32> %a, <vscale x 16 x i32> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv32i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 32 x i32> @llvm.vector.interleave2.nxv32i32(<vscale x 16 x i32> %a, <vscale x 16 x i32> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 32 x i32> %res
+;
+  %res = call <vscale x 32 x i32> @llvm.vector.interleave2.nxv32i32(<vscale x 16 x i32> %a, <vscale x 16 x i32> %b)
+  ret <vscale x 32 x i32> %res
+}
+
+define <vscale x 64 x i32> @interleave2_intrinsic_nxv64i32(<vscale x 32 x i32> %a, <vscale x 32 x i32> %b) {
+; CHECK-LABEL: 'interleave2_intrinsic_nxv64i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 64 x i32> @llvm.vector.interleave2.nxv64i32(<vscale x 32 x i32> %a, <vscale x 32 x i32> %b)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 64 x i32> %res
+;
+  %res = call <vscale x 64 x i32> @llvm.vector.interleave2.nxv64i32(<vscale x 32 x i32> %a, <vscale x 32 x i32> %b)
+  ret <vscale x 64 x i32> %res
+}
+
+; Fixed-length deinterleave2 intrinsics.
+
+define { <1 x i32>, <1 x i32> } @deinterleave2_intrinsic_v2i32(<2 x i32> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_v2i32'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 7 for instruction: %res = call { <1 x i32>, <1 x i32> } @llvm.vector.deinterleave2.v2i32(<2 x i32> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i32>, <1 x i32> } %res
+;
+  %res = call { <1 x i32>, <1 x i32> } @llvm.vector.deinterleave2.v2i32(<2 x i32> %v)
+  ret { <1 x i32>, <1 x i32> } %res
+}
+
+define { <1 x i64>, <1 x i64> } @deinterleave2_intrinsic_v2i64(<2 x i64> %v) {
+; RV32-LABEL: 'deinterleave2_intrinsic_v2i64'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 15 for instruction: %res = call { <1 x i64>, <1 x i64> } @llvm.vector.deinterleave2.v2i64(<2 x i64> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i64>, <1 x i64> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_v2i64'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 7 for instruction: %res = call { <1 x i64>, <1 x i64> } @llvm.vector.deinterleave2.v2i64(<2 x i64> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i64>, <1 x i64> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_v2i64'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 15 for instruction: %res = call { <1 x i64>, <1 x i64> } @llvm.vector.deinterleave2.v2i64(<2 x i64> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i64>, <1 x i64> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_v2i64'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call { <1 x i64>, <1 x i64> } @llvm.vector.deinterleave2.v2i64(<2 x i64> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i64>, <1 x i64> } %res
+;
+  %res = call { <1 x i64>, <1 x i64> } @llvm.vector.deinterleave2.v2i64(<2 x i64> %v)
+  ret { <1 x i64>, <1 x i64> } %res
+}
+
+define { <2 x i1>, <2 x i1> } @deinterleave2_intrinsic_v4i1(<4 x i1> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_v4i1'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 31 for instruction: %res = call { <2 x i1>, <2 x i1> } @llvm.vector.deinterleave2.v4i1(<4 x i1> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i1>, <2 x i1> } %res
+;
+  %res = call { <2 x i1>, <2 x i1> } @llvm.vector.deinterleave2.v4i1(<4 x i1> %v)
+  ret { <2 x i1>, <2 x i1> } %res
+}
+
+define { <2 x i8>, <2 x i8> } @deinterleave2_intrinsic_v4i8(<4 x i8> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_v4i8'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = call { <2 x i8>, <2 x i8> } @llvm.vector.deinterleave2.v4i8(<4 x i8> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i8>, <2 x i8> } %res
+;
+  %res = call { <2 x i8>, <2 x i8> } @llvm.vector.deinterleave2.v4i8(<4 x i8> %v)
+  ret { <2 x i8>, <2 x i8> } %res
+}
+
+define { <2 x i32>, <2 x i32> } @deinterleave2_intrinsic_v4i32(<4 x i32> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_v4i32'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = call { <2 x i32>, <2 x i32> } @llvm.vector.deinterleave2.v4i32(<4 x i32> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i32>, <2 x i32> } %res
+;
+  %res = call { <2 x i32>, <2 x i32> } @llvm.vector.deinterleave2.v4i32(<4 x i32> %v)
+  ret { <2 x i32>, <2 x i32> } %res
+}
+
+define { <2 x i64>, <2 x i64> } @deinterleave2_intrinsic_v4i64(<4 x i64> %v) {
+; RV32-LABEL: 'deinterleave2_intrinsic_v4i64'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 43 for instruction: %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i64>, <2 x i64> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_v4i64'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i64>, <2 x i64> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_v4i64'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 43 for instruction: %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i64>, <2 x i64> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_v4i64'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i64>, <2 x i64> } %res
+;
+  %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
+  ret { <2 x i64>, <2 x i64> } %res
+}
+
+define { <4 x i16>, <4 x i16> } @deinterleave2_intrinsic_v8i16(<8 x i16> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_v8i16'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 39 for instruction: %res = call { <4 x i16>, <4 x i16> } @llvm.vector.deinterleave2.v8i16(<8 x i16> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i16>, <4 x i16> } %res
+;
+  %res = call { <4 x i16>, <4 x i16> } @llvm.vector.deinterleave2.v8i16(<8 x i16> %v)
+  ret { <4 x i16>, <4 x i16> } %res
+}
+
+define { <4 x i32>, <4 x i32> } @deinterleave2_intrinsic_v8i32(<8 x i32> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_v8i32'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 39 for instruction: %res = call { <4 x i32>, <4 x i32> } @llvm.vector.deinterleave2.v8i32(<8 x i32> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i32>, <4 x i32> } %res
+;
+  %res = call { <4 x i32>, <4 x i32> } @llvm.vector.deinterleave2.v8i32(<8 x i32> %v)
+  ret { <4 x i32>, <4 x i32> } %res
+}
+
+define { <4 x i64>, <4 x i64> } @deinterleave2_intrinsic_v8i64(<8 x i64> %v) {
+; RV32-LABEL: 'deinterleave2_intrinsic_v8i64'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 165 for instruction: %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i64>, <4 x i64> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_v8i64'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 45 for instruction: %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i64>, <4 x i64> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_v8i64'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 165 for instruction: %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i64>, <4 x i64> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_v8i64'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i64>, <4 x i64> } %res
+;
+  %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
+  ret { <4 x i64>, <4 x i64> } %res
+}
+
+define { <8 x i32>, <8 x i32> } @deinterleave2_intrinsic_v16i32(<16 x i32> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_v16i32'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 93 for instruction: %res = call { <8 x i32>, <8 x i32> } @llvm.vector.deinterleave2.v16i32(<16 x i32> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <8 x i32>, <8 x i32> } %res
+;
+  %res = call { <8 x i32>, <8 x i32> } @llvm.vector.deinterleave2.v16i32(<16 x i32> %v)
+  ret { <8 x i32>, <8 x i32> } %res
+}
+
+define { <16 x i32>, <16 x i32> } @deinterleave2_intrinsic_v32i32(<32 x i32> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_v32i32'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 189 for instruction: %res = call { <16 x i32>, <16 x i32> } @llvm.vector.deinterleave2.v32i32(<32 x i32> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <16 x i32>, <16 x i32> } %res
+;
+  %res = call { <16 x i32>, <16 x i32> } @llvm.vector.deinterleave2.v32i32(<32 x i32> %v)
+  ret { <16 x i32>, <16 x i32> } %res
+}
+
+; Scalable deinterleave2 intrinsics.
+
+define { <vscale x 1 x i32>, <vscale x 1 x i32> } @deinterleave2_intrinsic_nxv2i32(<vscale x 2 x i32> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_nxv2i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.vector.deinterleave2.nxv2i32(<vscale x 2 x i32> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 1 x i32>, <vscale x 1 x i32> } %res
+;
+  %res = call { <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.vector.deinterleave2.nxv2i32(<vscale x 2 x i32> %v)
+  ret { <vscale x 1 x i32>, <vscale x 1 x i32> } %res
+}
+
+define { <vscale x 2 x i32>, <vscale x 2 x i32> } @deinterleave2_intrinsic_nxv4i32(<vscale x 4 x i32> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_nxv4i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.vector.deinterleave2.nxv4i32(<vscale x 4 x i32> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x i32>, <vscale x 2 x i32> } %res
+;
+  %res = call { <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.vector.deinterleave2.nxv4i32(<vscale x 4 x i32> %v)
+  ret { <vscale x 2 x i32>, <vscale x 2 x i32> } %res
+}
+
+define { <vscale x 2 x double>, <vscale x 2 x double> } @deinterleave2_intrinsic_nxv4f64(<vscale x 4 x double> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_nxv4f64'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x double>, <vscale x 2 x double> } %res
+;
+  %res = call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double> %v)
+  ret { <vscale x 2 x double>, <vscale x 2 x double> } %res
+}
+
+define { <vscale x 4 x half>, <vscale x 4 x half> } @deinterleave2_intrinsic_nxv8f16(<vscale x 8 x half> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_nxv8f16'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x half>, <vscale x 4 x half> } @llvm.vector.deinterleave2.nxv8f16(<vscale x 8 x half> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x half>, <vscale x 4 x half> } %res
+;
+  %res = call { <vscale x 4 x half>, <vscale x 4 x half> } @llvm.vector.deinterleave2.nxv8f16(<vscale x 8 x half> %v)
+  ret { <vscale x 4 x half>, <vscale x 4 x half> } %res
+}
+
+define { <vscale x 4 x i32>, <vscale x 4 x i32> } @deinterleave2_intrinsic_nxv8i32(<vscale x 8 x i32> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_nxv8i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x i32>, <vscale x 4 x i32> } @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x i32>, <vscale x 4 x i32> } %res
+;
+  %res = call { <vscale x 4 x i32>, <vscale x 4 x i32> } @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32> %v)
+  ret { <vscale x 4 x i32>, <vscale x 4 x i32> } %res
+}
+
+define { <vscale x 4 x float>, <vscale x 4 x float> } @deinterleave2_intrinsic_nxv8f32(<vscale x 8 x float> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_nxv8f32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x float>, <vscale x 4 x float> } @llvm.vector.deinterleave2.nxv8f32(<vscale x 8 x float> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x float>, <vscale x 4 x float> } %res
+;
+  %res = call { <vscale x 4 x float>, <vscale x 4 x float> } @llvm.vector.deinterleave2.nxv8f32(<vscale x 8 x float> %v)
+  ret { <vscale x 4 x float>, <vscale x 4 x float> } %res
+}
+
+define { <vscale x 8 x i32>, <vscale x 8 x i32> } @deinterleave2_intrinsic_nxv16i32(<vscale x 16 x i32> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_nxv16i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 8 x i32>, <vscale x 8 x i32> } @llvm.vector.deinterleave2.nxv16i32(<vscale x 16 x i32> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i32>, <vscale x 8 x i32> } %res
+;
+  %res = call { <vscale x 8 x i32>, <vscale x 8 x i32> } @llvm.vector.deinterleave2.nxv16i32(<vscale x 16 x i32> %v)
+  ret { <vscale x 8 x i32>, <vscale x 8 x i32> } %res
+}
+
+define { <vscale x 8 x i64>, <vscale x 8 x i64> } @deinterleave2_intrinsic_nxv16i64(<vscale x 16 x i64> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_nxv16i64'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 8 x i64>, <vscale x 8 x i64> } @llvm.vector.deinterleave2.nxv16i64(<vscale x 16 x i64> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i64>, <vscale x 8 x i64> } %res
+;
+  %res = call { <vscale x 8 x i64>, <vscale x 8 x i64> } @llvm.vector.deinterleave2.nxv16i64(<vscale x 16 x i64> %v)
+  ret { <vscale x 8 x i64>, <vscale x 8 x i64> } %res
+}
+
+define { <vscale x 16 x i32>, <vscale x 16 x i32> } @deinterleave2_intrinsic_nxv32i32(<vscale x 32 x i32> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_nxv32i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 16 x i32>, <vscale x 16 x i32> } @llvm.vector.deinterleave2.nxv32i32(<vscale x 32 x i32> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 16 x i32>, <vscale x 16 x i32> } %res
+;
+  %res = call { <vscale x 16 x i32>, <vscale x 16 x i32> } @llvm.vector.deinterleave2.nxv32i32(<vscale x 32 x i32> %v)
+  ret { <vscale x 16 x i32>, <vscale x 16 x i32> } %res
+}
+
+define { <vscale x 32 x i32>, <vscale x 32 x i32> } @deinterleave2_intrinsic_nxv64i32(<vscale x 64 x i32> %v) {
+; CHECK-LABEL: 'deinterleave2_intrinsic_nxv64i32'
+; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 32 x i32>, <vscale x 32 x i32> } @llvm.vector.deinterleave2.nxv64i32(<vscale x 64 x i32> %v)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 32 x i32>, <vscale x 32 x i32> } %res
+;
+  %res = call { <vscale x 32 x i32>, <vscale x 32 x i32> } @llvm.vector.deinterleave2.nxv64i32(<vscale x 64 x i32> %v)
+  ret { <vscale x 32 x i32>, <vscale x 32 x i32> } %res
+}

>From 9e12b613c10714521aac7550d14b698fe802daa3 Mon Sep 17 00:00:00 2001
From: Mingliang Liu <liumingliang.dev at bytedance.com>
Date: Wed, 23 Sep 2026 17:43:43 +0800
Subject: [PATCH 2/3] [RISCV] Teach TTI recognize the cost of [de]interleave2
 intrinsic

---
 .../Target/RISCV/RISCVTargetTransformInfo.cpp |  95 +++
 .../CostModel/RISCV/shuffle-interleave.ll     | 650 ++++++++++++++----
 2 files changed, 630 insertions(+), 115 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 7f65e3dd4456a2..7102bfe724a728 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -733,6 +733,54 @@ InstructionCost RISCVTTIImpl::getSlideCost(FixedVectorType *Tp,
   return FirstSlideCost + SecondSlideCost + MaskCost;
 }
 
+/// Return the type used to cost vzip.vv, whose LMUL represents the
+/// interleaved destination EMUL. Return std::nullopt if illegal.
+static std::optional<MVT> getZvzipVZIPCostVT(MVT InterleavedVT,
+                                             const RISCVSubtarget &ST,
+                                             const RISCVTargetLowering &TLI) {
+  if (!InterleavedVT.getVectorElementCount().isKnownEven())
+    return std::nullopt;
+
+  MVT CostVT = InterleavedVT;
+  if (InterleavedVT.isFixedLengthVector()) {
+    MVT SourceVT = InterleavedVT.getHalfNumVectorElementsVT();
+    CostVT = TLI.getContainerForFixedLengthVector(SourceVT)
+                 .getDoubleNumVectorElementsVT();
+  }
+
+  unsigned EltBits = CostVT.getScalarSizeInBits();
+  unsigned MinSize = CostVT.getSizeInBits().getKnownMinValue();
+  unsigned LMULOctuple = MinSize / (RISCV::RVVBitsPerBlock / 8);
+  // Perform the 2 * SEW <= LMUL * min(ELEN, VLEN) check.
+  if (EltBits * 16 > LMULOctuple * std::min(ST.getELen(), ST.getRealMinVLen()))
+    return std::nullopt;
+  return CostVT;
+}
+
+/// Return the type used to cost vunzipe.v/vunzipo.v, whose LMUL represents
+/// the interleaved source EMUL. Return std::nullopt if illegal.
+static std::optional<MVT> getZvzipVUNZIPCostVT(MVT InterleavedVT,
+                                               const RISCVTargetLowering &TLI) {
+  if (!InterleavedVT.getVectorElementCount().isKnownEven())
+    return std::nullopt;
+
+  MVT CostVT = InterleavedVT;
+  // lowerZvzipVUNZIP widens the source container if halving it would produce
+  // an illegal result type. Apply the same rule here so the cost uses the
+  // source LMUL selected by ISel.
+  if (InterleavedVT.isFixedLengthVector()) {
+    CostVT = TLI.getContainerForFixedLengthVector(InterleavedVT);
+    if (CostVT.getVectorMinNumElements() == 1 ||
+        !TLI.isTypeLegal(CostVT.getHalfNumVectorElementsVT()))
+      CostVT = CostVT.getDoubleNumVectorElementsVT();
+  }
+
+  MVT DeinterleavedVT = CostVT.getHalfNumVectorElementsVT();
+  if (RISCVTargetLowering::getLMUL(DeinterleavedVT) == RISCVVType::LMUL_8)
+    return std::nullopt;
+  return CostVT;
+}
+
 InstructionCost RISCVTTIImpl::getShuffleCost(
     TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy,
     TTI::TargetCostKind CostKind, ArrayRef<int> Mask, int Index,
@@ -1898,6 +1946,53 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
                                     ValLT.second, CostKind);
     return Cost;
   }
+  case Intrinsic::vector_interleave2:
+  case Intrinsic::vector_deinterleave2: {
+    if (!ST->hasStdExtZvzip())
+      break;
+
+    bool IsInterleave = ICA.getID() == Intrinsic::vector_interleave2;
+    Type *InterleavedTy = IsInterleave ? RetTy : ICA.getArgTypes().front();
+    // ISel does not select vzip.vv if either interleave2 input is undef.
+    if (IsInterleave && !ICA.isTypeBasedOnly() &&
+        any_of(ICA.getArgs(),
+               [](const Value *Arg) { return isa<UndefValue>(Arg); }))
+      break;
+    if (InterleavedTy->getScalarSizeInBits() == 1)
+      break;
+
+    if (auto *FVT = dyn_cast<FixedVectorType>(InterleavedTy)) {
+      if (IsInterleave) {
+        unsigned VF = FVT->getNumElements() / 2;
+        auto *HalfFVT = FixedVectorType::getHalfElementsVectorType(FVT);
+        return getShuffleCost(TTI::SK_PermuteTwoSrc, FVT, HalfFVT, CostKind,
+                              createInterleaveMask(VF, 2), 0, nullptr);
+      }
+
+      auto *HalfFVT = FixedVectorType::getHalfElementsVectorType(FVT);
+      unsigned VF = HalfFVT->getNumElements();
+      InstructionCost Cost = 0;
+      for (unsigned Start = 0; Start != 2; ++Start)
+        Cost += getShuffleCost(TTI::SK_PermuteSingleSrc, HalfFVT, FVT, CostKind,
+                               createStrideMask(Start, 2, VF), 0, nullptr);
+      return Cost;
+    }
+
+    std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(InterleavedTy);
+    if (!LT.second.isScalableVector())
+      break;
+    if (IsInterleave) {
+      if (std::optional<MVT> CostVT = getZvzipVZIPCostVT(LT.second, *ST, *TLI))
+        return LT.first *
+               getRISCVInstructionCost(RISCV::VZIP_VV, *CostVT, CostKind);
+    } else if (std::optional<MVT> CostVT =
+                   getZvzipVUNZIPCostVT(LT.second, *TLI)) {
+      return LT.first *
+             getRISCVInstructionCost({RISCV::VUNZIPE_V, RISCV::VUNZIPO_V},
+                                     *CostVT, CostKind);
+    }
+    break;
+  }
   }
 
   if (ST->hasVInstructions() && RetTy->isVectorTy()) {
diff --git a/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll b/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll
index c988e45b0f08e7..9cf20debf3ef78 100644
--- a/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll
+++ b/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll
@@ -131,9 +131,21 @@ define {<8 x i32>, <8 x i32>} @deinterleave_2_m2_dest(<16 x i32> %v) {
 ; the cost of fixed vector may seems weird.
 
 define <2 x i32> @interleave2_intrinsic_v2i32(<1 x i32> %a, <1 x i32> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_v2i32'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call <2 x i32> @llvm.vector.interleave2.v2i32(<1 x i32> %a, <1 x i32> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %res
+; RV32-LABEL: 'interleave2_intrinsic_v2i32'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call <2 x i32> @llvm.vector.interleave2.v2i32(<1 x i32> %a, <1 x i32> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_v2i32'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call <2 x i32> @llvm.vector.interleave2.v2i32(<1 x i32> %a, <1 x i32> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_v2i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <2 x i32> @llvm.vector.interleave2.v2i32(<1 x i32> %a, <1 x i32> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_v2i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <2 x i32> @llvm.vector.interleave2.v2i32(<1 x i32> %a, <1 x i32> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %res
 ;
   %res = call <2 x i32> @llvm.vector.interleave2.v2i32(<1 x i32> %a, <1 x i32> %b)
   ret <2 x i32> %res
@@ -149,11 +161,11 @@ define <2 x i64> @interleave2_intrinsic_v2i64(<1 x i64> %a, <1 x i64> %b) {
 ; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %res
 ;
 ; ZVZIP-LABEL: 'interleave2_intrinsic_v2i64'
-; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %res = call <2 x i64> @llvm.vector.interleave2.v2i64(<1 x i64> %a, <1 x i64> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <2 x i64> @llvm.vector.interleave2.v2i64(<1 x i64> %a, <1 x i64> %b)
 ; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %res
 ;
 ; ZVE32-LABEL: 'interleave2_intrinsic_v2i64'
-; ZVE32-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call <2 x i64> @llvm.vector.interleave2.v2i64(<1 x i64> %a, <1 x i64> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %res = call <2 x i64> @llvm.vector.interleave2.v2i64(<1 x i64> %a, <1 x i64> %b)
 ; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %res
 ;
   %res = call <2 x i64> @llvm.vector.interleave2.v2i64(<1 x i64> %a, <1 x i64> %b)
@@ -170,18 +182,42 @@ define <4 x i1> @interleave2_intrinsic_v4i1(<2 x i1> %a, <2 x i1> %b) {
 }
 
 define <4 x i8> @interleave2_intrinsic_v4i8(<2 x i8> %a, <2 x i8> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_v4i8'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 18 for instruction: %res = call <4 x i8> @llvm.vector.interleave2.v4i8(<2 x i8> %a, <2 x i8> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i8> %res
+; RV32-LABEL: 'interleave2_intrinsic_v4i8'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 18 for instruction: %res = call <4 x i8> @llvm.vector.interleave2.v4i8(<2 x i8> %a, <2 x i8> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i8> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_v4i8'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 18 for instruction: %res = call <4 x i8> @llvm.vector.interleave2.v4i8(<2 x i8> %a, <2 x i8> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i8> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_v4i8'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <4 x i8> @llvm.vector.interleave2.v4i8(<2 x i8> %a, <2 x i8> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i8> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_v4i8'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <4 x i8> @llvm.vector.interleave2.v4i8(<2 x i8> %a, <2 x i8> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i8> %res
 ;
   %res = call <4 x i8> @llvm.vector.interleave2.v4i8(<2 x i8> %a, <2 x i8> %b)
   ret <4 x i8> %res
 }
 
 define <4 x i32> @interleave2_intrinsic_v4i32(<2 x i32> %a, <2 x i32> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_v4i32'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 18 for instruction: %res = call <4 x i32> @llvm.vector.interleave2.v4i32(<2 x i32> %a, <2 x i32> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %res
+; RV32-LABEL: 'interleave2_intrinsic_v4i32'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 18 for instruction: %res = call <4 x i32> @llvm.vector.interleave2.v4i32(<2 x i32> %a, <2 x i32> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_v4i32'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 18 for instruction: %res = call <4 x i32> @llvm.vector.interleave2.v4i32(<2 x i32> %a, <2 x i32> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_v4i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <4 x i32> @llvm.vector.interleave2.v4i32(<2 x i32> %a, <2 x i32> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_v4i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <4 x i32> @llvm.vector.interleave2.v4i32(<2 x i32> %a, <2 x i32> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %res
 ;
   %res = call <4 x i32> @llvm.vector.interleave2.v4i32(<2 x i32> %a, <2 x i32> %b)
   ret <4 x i32> %res
@@ -197,11 +233,11 @@ define <4 x i64> @interleave2_intrinsic_v4i64(<2 x i64> %a, <2 x i64> %b) {
 ; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %res
 ;
 ; ZVZIP-LABEL: 'interleave2_intrinsic_v4i64'
-; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 57 for instruction: %res = call <4 x i64> @llvm.vector.interleave2.v4i64(<2 x i64> %a, <2 x i64> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <4 x i64> @llvm.vector.interleave2.v4i64(<2 x i64> %a, <2 x i64> %b)
 ; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %res
 ;
 ; ZVE32-LABEL: 'interleave2_intrinsic_v4i64'
-; ZVE32-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call <4 x i64> @llvm.vector.interleave2.v4i64(<2 x i64> %a, <2 x i64> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %res = call <4 x i64> @llvm.vector.interleave2.v4i64(<2 x i64> %a, <2 x i64> %b)
 ; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %res
 ;
   %res = call <4 x i64> @llvm.vector.interleave2.v4i64(<2 x i64> %a, <2 x i64> %b)
@@ -209,18 +245,42 @@ define <4 x i64> @interleave2_intrinsic_v4i64(<2 x i64> %a, <2 x i64> %b) {
 }
 
 define <8 x i16> @interleave2_intrinsic_v8i16(<4 x i16> %a, <4 x i16> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_v8i16'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 38 for instruction: %res = call <8 x i16> @llvm.vector.interleave2.v8i16(<4 x i16> %a, <4 x i16> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %res
+; RV32-LABEL: 'interleave2_intrinsic_v8i16'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 38 for instruction: %res = call <8 x i16> @llvm.vector.interleave2.v8i16(<4 x i16> %a, <4 x i16> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_v8i16'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 38 for instruction: %res = call <8 x i16> @llvm.vector.interleave2.v8i16(<4 x i16> %a, <4 x i16> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_v8i16'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <8 x i16> @llvm.vector.interleave2.v8i16(<4 x i16> %a, <4 x i16> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_v8i16'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <8 x i16> @llvm.vector.interleave2.v8i16(<4 x i16> %a, <4 x i16> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %res
 ;
   %res = call <8 x i16> @llvm.vector.interleave2.v8i16(<4 x i16> %a, <4 x i16> %b)
   ret <8 x i16> %res
 }
 
 define <8 x i32> @interleave2_intrinsic_v8i32(<4 x i32> %a, <4 x i32> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_v8i32'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 45 for instruction: %res = call <8 x i32> @llvm.vector.interleave2.v8i32(<4 x i32> %a, <4 x i32> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
+; RV32-LABEL: 'interleave2_intrinsic_v8i32'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 45 for instruction: %res = call <8 x i32> @llvm.vector.interleave2.v8i32(<4 x i32> %a, <4 x i32> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_v8i32'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 45 for instruction: %res = call <8 x i32> @llvm.vector.interleave2.v8i32(<4 x i32> %a, <4 x i32> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_v8i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <8 x i32> @llvm.vector.interleave2.v8i32(<4 x i32> %a, <4 x i32> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_v8i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %res = call <8 x i32> @llvm.vector.interleave2.v8i32(<4 x i32> %a, <4 x i32> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res
 ;
   %res = call <8 x i32> @llvm.vector.interleave2.v8i32(<4 x i32> %a, <4 x i32> %b)
   ret <8 x i32> %res
@@ -236,18 +296,42 @@ define <8 x i32> @interleave2_intrinsic_v8i32_poison(<4 x i32> %a) {
 }
 
 define <16 x i32> @interleave2_intrinsic_v16i32(<8 x i32> %a, <8 x i32> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_v16i32'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 93 for instruction: %res = call <16 x i32> @llvm.vector.interleave2.v16i32(<8 x i32> %a, <8 x i32> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i32> %res
+; RV32-LABEL: 'interleave2_intrinsic_v16i32'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 93 for instruction: %res = call <16 x i32> @llvm.vector.interleave2.v16i32(<8 x i32> %a, <8 x i32> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i32> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_v16i32'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 93 for instruction: %res = call <16 x i32> @llvm.vector.interleave2.v16i32(<8 x i32> %a, <8 x i32> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_v16i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = call <16 x i32> @llvm.vector.interleave2.v16i32(<8 x i32> %a, <8 x i32> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_v16i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = call <16 x i32> @llvm.vector.interleave2.v16i32(<8 x i32> %a, <8 x i32> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i32> %res
 ;
   %res = call <16 x i32> @llvm.vector.interleave2.v16i32(<8 x i32> %a, <8 x i32> %b)
   ret <16 x i32> %res
 }
 
 define <32 x i32> @interleave2_intrinsic_v32i32(<16 x i32> %a, <16 x i32> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_v32i32'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 189 for instruction: %res = call <32 x i32> @llvm.vector.interleave2.v32i32(<16 x i32> %a, <16 x i32> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i32> %res
+; RV32-LABEL: 'interleave2_intrinsic_v32i32'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 189 for instruction: %res = call <32 x i32> @llvm.vector.interleave2.v32i32(<16 x i32> %a, <16 x i32> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i32> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_v32i32'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 189 for instruction: %res = call <32 x i32> @llvm.vector.interleave2.v32i32(<16 x i32> %a, <16 x i32> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_v32i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 47 for instruction: %res = call <32 x i32> @llvm.vector.interleave2.v32i32(<16 x i32> %a, <16 x i32> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_v32i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 47 for instruction: %res = call <32 x i32> @llvm.vector.interleave2.v32i32(<16 x i32> %a, <16 x i32> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i32> %res
 ;
   %res = call <32 x i32> @llvm.vector.interleave2.v32i32(<16 x i32> %a, <16 x i32> %b)
   ret <32 x i32> %res
@@ -256,54 +340,126 @@ define <32 x i32> @interleave2_intrinsic_v32i32(<16 x i32> %a, <16 x i32> %b) {
 ; Scalable interleave2 intrinsics.
 
 define <vscale x 2 x i32> @interleave2_intrinsic_nxv2i32(<vscale x 1 x i32> %a, <vscale x 1 x i32> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_nxv2i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 2 x i32> @llvm.vector.interleave2.nxv2i32(<vscale x 1 x i32> %a, <vscale x 1 x i32> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i32> %res
+; RV32-LABEL: 'interleave2_intrinsic_nxv2i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 2 x i32> @llvm.vector.interleave2.nxv2i32(<vscale x 1 x i32> %a, <vscale x 1 x i32> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i32> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_nxv2i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 2 x i32> @llvm.vector.interleave2.nxv2i32(<vscale x 1 x i32> %a, <vscale x 1 x i32> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_nxv2i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %res = call <vscale x 2 x i32> @llvm.vector.interleave2.nxv2i32(<vscale x 1 x i32> %a, <vscale x 1 x i32> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_nxv2i32'
+; ZVE32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 2 x i32> @llvm.vector.interleave2.nxv2i32(<vscale x 1 x i32> %a, <vscale x 1 x i32> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i32> %res
 ;
   %res = call <vscale x 2 x i32> @llvm.vector.interleave2.nxv2i32(<vscale x 1 x i32> %a, <vscale x 1 x i32> %b)
   ret <vscale x 2 x i32> %res
 }
 
 define <vscale x 2 x i64> @interleave2_intrinsic_nxv2i64(<vscale x 1 x i64> %a, <vscale x 1 x i64> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_nxv2i64'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 2 x i64> @llvm.vector.interleave2.nxv2i64(<vscale x 1 x i64> %a, <vscale x 1 x i64> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i64> %res
+; RV32-LABEL: 'interleave2_intrinsic_nxv2i64'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 2 x i64> @llvm.vector.interleave2.nxv2i64(<vscale x 1 x i64> %a, <vscale x 1 x i64> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i64> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_nxv2i64'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 2 x i64> @llvm.vector.interleave2.nxv2i64(<vscale x 1 x i64> %a, <vscale x 1 x i64> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i64> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_nxv2i64'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call <vscale x 2 x i64> @llvm.vector.interleave2.nxv2i64(<vscale x 1 x i64> %a, <vscale x 1 x i64> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i64> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_nxv2i64'
+; ZVE32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 2 x i64> @llvm.vector.interleave2.nxv2i64(<vscale x 1 x i64> %a, <vscale x 1 x i64> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 2 x i64> %res
 ;
   %res = call <vscale x 2 x i64> @llvm.vector.interleave2.nxv2i64(<vscale x 1 x i64> %a, <vscale x 1 x i64> %b)
   ret <vscale x 2 x i64> %res
 }
 
 define <vscale x 4 x i32> @interleave2_intrinsic_nxv4i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_nxv4i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 4 x i32> @llvm.vector.interleave2.nxv4i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x i32> %res
+; RV32-LABEL: 'interleave2_intrinsic_nxv4i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 4 x i32> @llvm.vector.interleave2.nxv4i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x i32> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_nxv4i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 4 x i32> @llvm.vector.interleave2.nxv4i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_nxv4i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call <vscale x 4 x i32> @llvm.vector.interleave2.nxv4i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_nxv4i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call <vscale x 4 x i32> @llvm.vector.interleave2.nxv4i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x i32> %res
 ;
   %res = call <vscale x 4 x i32> @llvm.vector.interleave2.nxv4i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b)
   ret <vscale x 4 x i32> %res
 }
 
 define <vscale x 4 x double> @interleave2_intrinsic_nxv4f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_nxv4f64'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 4 x double> @llvm.vector.interleave2.nxv4f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x double> %res
+; RV32-LABEL: 'interleave2_intrinsic_nxv4f64'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 4 x double> @llvm.vector.interleave2.nxv4f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x double> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_nxv4f64'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 4 x double> @llvm.vector.interleave2.nxv4f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x double> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_nxv4f64'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call <vscale x 4 x double> @llvm.vector.interleave2.nxv4f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x double> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_nxv4f64'
+; ZVE32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 4 x double> @llvm.vector.interleave2.nxv4f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x double> %res
 ;
   %res = call <vscale x 4 x double> @llvm.vector.interleave2.nxv4f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b)
   ret <vscale x 4 x double> %res
 }
 
 define <vscale x 8 x half> @interleave2_intrinsic_nxv8f16(<vscale x 4 x half> %a, <vscale x 4 x half> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_nxv8f16'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x half> @llvm.vector.interleave2.nxv8f16(<vscale x 4 x half> %a, <vscale x 4 x half> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x half> %res
+; RV32-LABEL: 'interleave2_intrinsic_nxv8f16'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x half> @llvm.vector.interleave2.nxv8f16(<vscale x 4 x half> %a, <vscale x 4 x half> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x half> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_nxv8f16'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x half> @llvm.vector.interleave2.nxv8f16(<vscale x 4 x half> %a, <vscale x 4 x half> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x half> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_nxv8f16'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call <vscale x 8 x half> @llvm.vector.interleave2.nxv8f16(<vscale x 4 x half> %a, <vscale x 4 x half> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x half> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_nxv8f16'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call <vscale x 8 x half> @llvm.vector.interleave2.nxv8f16(<vscale x 4 x half> %a, <vscale x 4 x half> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x half> %res
 ;
   %res = call <vscale x 8 x half> @llvm.vector.interleave2.nxv8f16(<vscale x 4 x half> %a, <vscale x 4 x half> %b)
   ret <vscale x 8 x half> %res
 }
 
 define <vscale x 8 x i32> @interleave2_intrinsic_nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_nxv8i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x i32> %res
+; RV32-LABEL: 'interleave2_intrinsic_nxv8i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x i32> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_nxv8i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_nxv8i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_nxv8i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x i32> %res
 ;
   %res = call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
   ret <vscale x 8 x i32> %res
@@ -319,45 +475,105 @@ define <vscale x 8 x i32> @interleave2_intrinsic_nxv8i32_poison(<vscale x 4 x i3
 }
 
 define <vscale x 8 x float> @interleave2_intrinsic_nxv8f32(<vscale x 4 x float> %a, <vscale x 4 x float> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_nxv8f32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x float> @llvm.vector.interleave2.nxv8f32(<vscale x 4 x float> %a, <vscale x 4 x float> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x float> %res
+; RV32-LABEL: 'interleave2_intrinsic_nxv8f32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x float> @llvm.vector.interleave2.nxv8f32(<vscale x 4 x float> %a, <vscale x 4 x float> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x float> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_nxv8f32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 8 x float> @llvm.vector.interleave2.nxv8f32(<vscale x 4 x float> %a, <vscale x 4 x float> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x float> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_nxv8f32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call <vscale x 8 x float> @llvm.vector.interleave2.nxv8f32(<vscale x 4 x float> %a, <vscale x 4 x float> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x float> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_nxv8f32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call <vscale x 8 x float> @llvm.vector.interleave2.nxv8f32(<vscale x 4 x float> %a, <vscale x 4 x float> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x float> %res
 ;
   %res = call <vscale x 8 x float> @llvm.vector.interleave2.nxv8f32(<vscale x 4 x float> %a, <vscale x 4 x float> %b)
   ret <vscale x 8 x float> %res
 }
 
 define <vscale x 16 x i32> @interleave2_intrinsic_nxv16i32(<vscale x 8 x i32> %a, <vscale x 8 x i32> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_nxv16i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> %a, <vscale x 8 x i32> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i32> %res
+; RV32-LABEL: 'interleave2_intrinsic_nxv16i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> %a, <vscale x 8 x i32> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i32> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_nxv16i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> %a, <vscale x 8 x i32> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_nxv16i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> %a, <vscale x 8 x i32> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_nxv16i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> %a, <vscale x 8 x i32> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i32> %res
 ;
   %res = call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> %a, <vscale x 8 x i32> %b)
   ret <vscale x 16 x i32> %res
 }
 
 define <vscale x 16 x i64> @interleave2_intrinsic_nxv16i64(<vscale x 8 x i64> %a, <vscale x 8 x i64> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_nxv16i64'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 16 x i64> @llvm.vector.interleave2.nxv16i64(<vscale x 8 x i64> %a, <vscale x 8 x i64> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i64> %res
+; RV32-LABEL: 'interleave2_intrinsic_nxv16i64'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 16 x i64> @llvm.vector.interleave2.nxv16i64(<vscale x 8 x i64> %a, <vscale x 8 x i64> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i64> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_nxv16i64'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 16 x i64> @llvm.vector.interleave2.nxv16i64(<vscale x 8 x i64> %a, <vscale x 8 x i64> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i64> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_nxv16i64'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %res = call <vscale x 16 x i64> @llvm.vector.interleave2.nxv16i64(<vscale x 8 x i64> %a, <vscale x 8 x i64> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i64> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_nxv16i64'
+; ZVE32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 16 x i64> @llvm.vector.interleave2.nxv16i64(<vscale x 8 x i64> %a, <vscale x 8 x i64> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i64> %res
 ;
   %res = call <vscale x 16 x i64> @llvm.vector.interleave2.nxv16i64(<vscale x 8 x i64> %a, <vscale x 8 x i64> %b)
   ret <vscale x 16 x i64> %res
 }
 
 define <vscale x 32 x i32> @interleave2_intrinsic_nxv32i32(<vscale x 16 x i32> %a, <vscale x 16 x i32> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_nxv32i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 32 x i32> @llvm.vector.interleave2.nxv32i32(<vscale x 16 x i32> %a, <vscale x 16 x i32> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 32 x i32> %res
+; RV32-LABEL: 'interleave2_intrinsic_nxv32i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 32 x i32> @llvm.vector.interleave2.nxv32i32(<vscale x 16 x i32> %a, <vscale x 16 x i32> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 32 x i32> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_nxv32i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 32 x i32> @llvm.vector.interleave2.nxv32i32(<vscale x 16 x i32> %a, <vscale x 16 x i32> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 32 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_nxv32i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %res = call <vscale x 32 x i32> @llvm.vector.interleave2.nxv32i32(<vscale x 16 x i32> %a, <vscale x 16 x i32> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 32 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_nxv32i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %res = call <vscale x 32 x i32> @llvm.vector.interleave2.nxv32i32(<vscale x 16 x i32> %a, <vscale x 16 x i32> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 32 x i32> %res
 ;
   %res = call <vscale x 32 x i32> @llvm.vector.interleave2.nxv32i32(<vscale x 16 x i32> %a, <vscale x 16 x i32> %b)
   ret <vscale x 32 x i32> %res
 }
 
 define <vscale x 64 x i32> @interleave2_intrinsic_nxv64i32(<vscale x 32 x i32> %a, <vscale x 32 x i32> %b) {
-; CHECK-LABEL: 'interleave2_intrinsic_nxv64i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 64 x i32> @llvm.vector.interleave2.nxv64i32(<vscale x 32 x i32> %a, <vscale x 32 x i32> %b)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 64 x i32> %res
+; RV32-LABEL: 'interleave2_intrinsic_nxv64i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 64 x i32> @llvm.vector.interleave2.nxv64i32(<vscale x 32 x i32> %a, <vscale x 32 x i32> %b)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 64 x i32> %res
+;
+; RV64-LABEL: 'interleave2_intrinsic_nxv64i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call <vscale x 64 x i32> @llvm.vector.interleave2.nxv64i32(<vscale x 32 x i32> %a, <vscale x 32 x i32> %b)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 64 x i32> %res
+;
+; ZVZIP-LABEL: 'interleave2_intrinsic_nxv64i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %res = call <vscale x 64 x i32> @llvm.vector.interleave2.nxv64i32(<vscale x 32 x i32> %a, <vscale x 32 x i32> %b)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 64 x i32> %res
+;
+; ZVE32-LABEL: 'interleave2_intrinsic_nxv64i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %res = call <vscale x 64 x i32> @llvm.vector.interleave2.nxv64i32(<vscale x 32 x i32> %a, <vscale x 32 x i32> %b)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 64 x i32> %res
 ;
   %res = call <vscale x 64 x i32> @llvm.vector.interleave2.nxv64i32(<vscale x 32 x i32> %a, <vscale x 32 x i32> %b)
   ret <vscale x 64 x i32> %res
@@ -366,9 +582,21 @@ define <vscale x 64 x i32> @interleave2_intrinsic_nxv64i32(<vscale x 32 x i32> %
 ; Fixed-length deinterleave2 intrinsics.
 
 define { <1 x i32>, <1 x i32> } @deinterleave2_intrinsic_v2i32(<2 x i32> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_v2i32'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 7 for instruction: %res = call { <1 x i32>, <1 x i32> } @llvm.vector.deinterleave2.v2i32(<2 x i32> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i32>, <1 x i32> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_v2i32'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 7 for instruction: %res = call { <1 x i32>, <1 x i32> } @llvm.vector.deinterleave2.v2i32(<2 x i32> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i32>, <1 x i32> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_v2i32'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 7 for instruction: %res = call { <1 x i32>, <1 x i32> } @llvm.vector.deinterleave2.v2i32(<2 x i32> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i32>, <1 x i32> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_v2i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %res = call { <1 x i32>, <1 x i32> } @llvm.vector.deinterleave2.v2i32(<2 x i32> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i32>, <1 x i32> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_v2i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %res = call { <1 x i32>, <1 x i32> } @llvm.vector.deinterleave2.v2i32(<2 x i32> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i32>, <1 x i32> } %res
 ;
   %res = call { <1 x i32>, <1 x i32> } @llvm.vector.deinterleave2.v2i32(<2 x i32> %v)
   ret { <1 x i32>, <1 x i32> } %res
@@ -384,11 +612,11 @@ define { <1 x i64>, <1 x i64> } @deinterleave2_intrinsic_v2i64(<2 x i64> %v) {
 ; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i64>, <1 x i64> } %res
 ;
 ; ZVZIP-LABEL: 'deinterleave2_intrinsic_v2i64'
-; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 15 for instruction: %res = call { <1 x i64>, <1 x i64> } @llvm.vector.deinterleave2.v2i64(<2 x i64> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %res = call { <1 x i64>, <1 x i64> } @llvm.vector.deinterleave2.v2i64(<2 x i64> %v)
 ; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i64>, <1 x i64> } %res
 ;
 ; ZVE32-LABEL: 'deinterleave2_intrinsic_v2i64'
-; ZVE32-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call { <1 x i64>, <1 x i64> } @llvm.vector.deinterleave2.v2i64(<2 x i64> %v)
+; ZVE32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <1 x i64>, <1 x i64> } @llvm.vector.deinterleave2.v2i64(<2 x i64> %v)
 ; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <1 x i64>, <1 x i64> } %res
 ;
   %res = call { <1 x i64>, <1 x i64> } @llvm.vector.deinterleave2.v2i64(<2 x i64> %v)
@@ -405,18 +633,42 @@ define { <2 x i1>, <2 x i1> } @deinterleave2_intrinsic_v4i1(<4 x i1> %v) {
 }
 
 define { <2 x i8>, <2 x i8> } @deinterleave2_intrinsic_v4i8(<4 x i8> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_v4i8'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = call { <2 x i8>, <2 x i8> } @llvm.vector.deinterleave2.v4i8(<4 x i8> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i8>, <2 x i8> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_v4i8'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = call { <2 x i8>, <2 x i8> } @llvm.vector.deinterleave2.v4i8(<4 x i8> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i8>, <2 x i8> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_v4i8'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = call { <2 x i8>, <2 x i8> } @llvm.vector.deinterleave2.v4i8(<4 x i8> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i8>, <2 x i8> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_v4i8'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call { <2 x i8>, <2 x i8> } @llvm.vector.deinterleave2.v4i8(<4 x i8> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i8>, <2 x i8> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_v4i8'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call { <2 x i8>, <2 x i8> } @llvm.vector.deinterleave2.v4i8(<4 x i8> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i8>, <2 x i8> } %res
 ;
   %res = call { <2 x i8>, <2 x i8> } @llvm.vector.deinterleave2.v4i8(<4 x i8> %v)
   ret { <2 x i8>, <2 x i8> } %res
 }
 
 define { <2 x i32>, <2 x i32> } @deinterleave2_intrinsic_v4i32(<4 x i32> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_v4i32'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = call { <2 x i32>, <2 x i32> } @llvm.vector.deinterleave2.v4i32(<4 x i32> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i32>, <2 x i32> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_v4i32'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = call { <2 x i32>, <2 x i32> } @llvm.vector.deinterleave2.v4i32(<4 x i32> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i32>, <2 x i32> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_v4i32'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = call { <2 x i32>, <2 x i32> } @llvm.vector.deinterleave2.v4i32(<4 x i32> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i32>, <2 x i32> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_v4i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call { <2 x i32>, <2 x i32> } @llvm.vector.deinterleave2.v4i32(<4 x i32> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i32>, <2 x i32> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_v4i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call { <2 x i32>, <2 x i32> } @llvm.vector.deinterleave2.v4i32(<4 x i32> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i32>, <2 x i32> } %res
 ;
   %res = call { <2 x i32>, <2 x i32> } @llvm.vector.deinterleave2.v4i32(<4 x i32> %v)
   ret { <2 x i32>, <2 x i32> } %res
@@ -432,11 +684,11 @@ define { <2 x i64>, <2 x i64> } @deinterleave2_intrinsic_v4i64(<4 x i64> %v) {
 ; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i64>, <2 x i64> } %res
 ;
 ; ZVZIP-LABEL: 'deinterleave2_intrinsic_v4i64'
-; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 43 for instruction: %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 14 for instruction: %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
 ; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i64>, <2 x i64> } %res
 ;
 ; ZVE32-LABEL: 'deinterleave2_intrinsic_v4i64'
-; ZVE32-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
 ; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i64>, <2 x i64> } %res
 ;
   %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
@@ -444,18 +696,42 @@ define { <2 x i64>, <2 x i64> } @deinterleave2_intrinsic_v4i64(<4 x i64> %v) {
 }
 
 define { <4 x i16>, <4 x i16> } @deinterleave2_intrinsic_v8i16(<8 x i16> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_v8i16'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 39 for instruction: %res = call { <4 x i16>, <4 x i16> } @llvm.vector.deinterleave2.v8i16(<8 x i16> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i16>, <4 x i16> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_v8i16'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 39 for instruction: %res = call { <4 x i16>, <4 x i16> } @llvm.vector.deinterleave2.v8i16(<8 x i16> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i16>, <4 x i16> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_v8i16'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 39 for instruction: %res = call { <4 x i16>, <4 x i16> } @llvm.vector.deinterleave2.v8i16(<8 x i16> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i16>, <4 x i16> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_v8i16'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call { <4 x i16>, <4 x i16> } @llvm.vector.deinterleave2.v8i16(<8 x i16> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i16>, <4 x i16> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_v8i16'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call { <4 x i16>, <4 x i16> } @llvm.vector.deinterleave2.v8i16(<8 x i16> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i16>, <4 x i16> } %res
 ;
   %res = call { <4 x i16>, <4 x i16> } @llvm.vector.deinterleave2.v8i16(<8 x i16> %v)
   ret { <4 x i16>, <4 x i16> } %res
 }
 
 define { <4 x i32>, <4 x i32> } @deinterleave2_intrinsic_v8i32(<8 x i32> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_v8i32'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 39 for instruction: %res = call { <4 x i32>, <4 x i32> } @llvm.vector.deinterleave2.v8i32(<8 x i32> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i32>, <4 x i32> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_v8i32'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 39 for instruction: %res = call { <4 x i32>, <4 x i32> } @llvm.vector.deinterleave2.v8i32(<8 x i32> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i32>, <4 x i32> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_v8i32'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 39 for instruction: %res = call { <4 x i32>, <4 x i32> } @llvm.vector.deinterleave2.v8i32(<8 x i32> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i32>, <4 x i32> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_v8i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call { <4 x i32>, <4 x i32> } @llvm.vector.deinterleave2.v8i32(<8 x i32> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i32>, <4 x i32> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_v8i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %res = call { <4 x i32>, <4 x i32> } @llvm.vector.deinterleave2.v8i32(<8 x i32> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i32>, <4 x i32> } %res
 ;
   %res = call { <4 x i32>, <4 x i32> } @llvm.vector.deinterleave2.v8i32(<8 x i32> %v)
   ret { <4 x i32>, <4 x i32> } %res
@@ -471,11 +747,11 @@ define { <4 x i64>, <4 x i64> } @deinterleave2_intrinsic_v8i64(<8 x i64> %v) {
 ; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i64>, <4 x i64> } %res
 ;
 ; ZVZIP-LABEL: 'deinterleave2_intrinsic_v8i64'
-; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 165 for instruction: %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 38 for instruction: %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
 ; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i64>, <4 x i64> } %res
 ;
 ; ZVE32-LABEL: 'deinterleave2_intrinsic_v8i64'
-; ZVE32-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
 ; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i64>, <4 x i64> } %res
 ;
   %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
@@ -483,18 +759,42 @@ define { <4 x i64>, <4 x i64> } @deinterleave2_intrinsic_v8i64(<8 x i64> %v) {
 }
 
 define { <8 x i32>, <8 x i32> } @deinterleave2_intrinsic_v16i32(<16 x i32> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_v16i32'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 93 for instruction: %res = call { <8 x i32>, <8 x i32> } @llvm.vector.deinterleave2.v16i32(<16 x i32> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <8 x i32>, <8 x i32> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_v16i32'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 93 for instruction: %res = call { <8 x i32>, <8 x i32> } @llvm.vector.deinterleave2.v16i32(<16 x i32> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <8 x i32>, <8 x i32> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_v16i32'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 93 for instruction: %res = call { <8 x i32>, <8 x i32> } @llvm.vector.deinterleave2.v16i32(<16 x i32> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <8 x i32>, <8 x i32> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_v16i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call { <8 x i32>, <8 x i32> } @llvm.vector.deinterleave2.v16i32(<16 x i32> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <8 x i32>, <8 x i32> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_v16i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 44 for instruction: %res = call { <8 x i32>, <8 x i32> } @llvm.vector.deinterleave2.v16i32(<16 x i32> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <8 x i32>, <8 x i32> } %res
 ;
   %res = call { <8 x i32>, <8 x i32> } @llvm.vector.deinterleave2.v16i32(<16 x i32> %v)
   ret { <8 x i32>, <8 x i32> } %res
 }
 
 define { <16 x i32>, <16 x i32> } @deinterleave2_intrinsic_v32i32(<32 x i32> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_v32i32'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 189 for instruction: %res = call { <16 x i32>, <16 x i32> } @llvm.vector.deinterleave2.v32i32(<32 x i32> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <16 x i32>, <16 x i32> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_v32i32'
+; RV32-NEXT:  Cost Model: Found an estimated cost of 189 for instruction: %res = call { <16 x i32>, <16 x i32> } @llvm.vector.deinterleave2.v32i32(<32 x i32> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <16 x i32>, <16 x i32> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_v32i32'
+; RV64-NEXT:  Cost Model: Found an estimated cost of 189 for instruction: %res = call { <16 x i32>, <16 x i32> } @llvm.vector.deinterleave2.v32i32(<32 x i32> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <16 x i32>, <16 x i32> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_v32i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %res = call { <16 x i32>, <16 x i32> } @llvm.vector.deinterleave2.v32i32(<32 x i32> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <16 x i32>, <16 x i32> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_v32i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 148 for instruction: %res = call { <16 x i32>, <16 x i32> } @llvm.vector.deinterleave2.v32i32(<32 x i32> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <16 x i32>, <16 x i32> } %res
 ;
   %res = call { <16 x i32>, <16 x i32> } @llvm.vector.deinterleave2.v32i32(<32 x i32> %v)
   ret { <16 x i32>, <16 x i32> } %res
@@ -503,90 +803,210 @@ define { <16 x i32>, <16 x i32> } @deinterleave2_intrinsic_v32i32(<32 x i32> %v)
 ; Scalable deinterleave2 intrinsics.
 
 define { <vscale x 1 x i32>, <vscale x 1 x i32> } @deinterleave2_intrinsic_nxv2i32(<vscale x 2 x i32> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_nxv2i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.vector.deinterleave2.nxv2i32(<vscale x 2 x i32> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 1 x i32>, <vscale x 1 x i32> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_nxv2i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.vector.deinterleave2.nxv2i32(<vscale x 2 x i32> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 1 x i32>, <vscale x 1 x i32> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_nxv2i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.vector.deinterleave2.nxv2i32(<vscale x 2 x i32> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 1 x i32>, <vscale x 1 x i32> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_nxv2i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call { <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.vector.deinterleave2.nxv2i32(<vscale x 2 x i32> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 1 x i32>, <vscale x 1 x i32> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_nxv2i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %res = call { <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.vector.deinterleave2.nxv2i32(<vscale x 2 x i32> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 1 x i32>, <vscale x 1 x i32> } %res
 ;
   %res = call { <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.vector.deinterleave2.nxv2i32(<vscale x 2 x i32> %v)
   ret { <vscale x 1 x i32>, <vscale x 1 x i32> } %res
 }
 
 define { <vscale x 2 x i32>, <vscale x 2 x i32> } @deinterleave2_intrinsic_nxv4i32(<vscale x 4 x i32> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_nxv4i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.vector.deinterleave2.nxv4i32(<vscale x 4 x i32> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x i32>, <vscale x 2 x i32> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_nxv4i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.vector.deinterleave2.nxv4i32(<vscale x 4 x i32> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x i32>, <vscale x 2 x i32> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_nxv4i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.vector.deinterleave2.nxv4i32(<vscale x 4 x i32> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x i32>, <vscale x 2 x i32> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_nxv4i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call { <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.vector.deinterleave2.nxv4i32(<vscale x 4 x i32> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x i32>, <vscale x 2 x i32> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_nxv4i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call { <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.vector.deinterleave2.nxv4i32(<vscale x 4 x i32> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x i32>, <vscale x 2 x i32> } %res
 ;
   %res = call { <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.vector.deinterleave2.nxv4i32(<vscale x 4 x i32> %v)
   ret { <vscale x 2 x i32>, <vscale x 2 x i32> } %res
 }
 
 define { <vscale x 2 x double>, <vscale x 2 x double> } @deinterleave2_intrinsic_nxv4f64(<vscale x 4 x double> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_nxv4f64'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x double>, <vscale x 2 x double> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_nxv4f64'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x double>, <vscale x 2 x double> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_nxv4f64'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x double>, <vscale x 2 x double> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_nxv4f64'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x double>, <vscale x 2 x double> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_nxv4f64'
+; ZVE32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 2 x double>, <vscale x 2 x double> } %res
 ;
   %res = call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double> %v)
   ret { <vscale x 2 x double>, <vscale x 2 x double> } %res
 }
 
 define { <vscale x 4 x half>, <vscale x 4 x half> } @deinterleave2_intrinsic_nxv8f16(<vscale x 8 x half> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_nxv8f16'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x half>, <vscale x 4 x half> } @llvm.vector.deinterleave2.nxv8f16(<vscale x 8 x half> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x half>, <vscale x 4 x half> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_nxv8f16'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x half>, <vscale x 4 x half> } @llvm.vector.deinterleave2.nxv8f16(<vscale x 8 x half> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x half>, <vscale x 4 x half> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_nxv8f16'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x half>, <vscale x 4 x half> } @llvm.vector.deinterleave2.nxv8f16(<vscale x 8 x half> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x half>, <vscale x 4 x half> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_nxv8f16'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call { <vscale x 4 x half>, <vscale x 4 x half> } @llvm.vector.deinterleave2.nxv8f16(<vscale x 8 x half> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x half>, <vscale x 4 x half> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_nxv8f16'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %res = call { <vscale x 4 x half>, <vscale x 4 x half> } @llvm.vector.deinterleave2.nxv8f16(<vscale x 8 x half> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x half>, <vscale x 4 x half> } %res
 ;
   %res = call { <vscale x 4 x half>, <vscale x 4 x half> } @llvm.vector.deinterleave2.nxv8f16(<vscale x 8 x half> %v)
   ret { <vscale x 4 x half>, <vscale x 4 x half> } %res
 }
 
 define { <vscale x 4 x i32>, <vscale x 4 x i32> } @deinterleave2_intrinsic_nxv8i32(<vscale x 8 x i32> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_nxv8i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x i32>, <vscale x 4 x i32> } @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x i32>, <vscale x 4 x i32> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_nxv8i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x i32>, <vscale x 4 x i32> } @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x i32>, <vscale x 4 x i32> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_nxv8i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x i32>, <vscale x 4 x i32> } @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x i32>, <vscale x 4 x i32> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_nxv8i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call { <vscale x 4 x i32>, <vscale x 4 x i32> } @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x i32>, <vscale x 4 x i32> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_nxv8i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call { <vscale x 4 x i32>, <vscale x 4 x i32> } @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x i32>, <vscale x 4 x i32> } %res
 ;
   %res = call { <vscale x 4 x i32>, <vscale x 4 x i32> } @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32> %v)
   ret { <vscale x 4 x i32>, <vscale x 4 x i32> } %res
 }
 
 define { <vscale x 4 x float>, <vscale x 4 x float> } @deinterleave2_intrinsic_nxv8f32(<vscale x 8 x float> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_nxv8f32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x float>, <vscale x 4 x float> } @llvm.vector.deinterleave2.nxv8f32(<vscale x 8 x float> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x float>, <vscale x 4 x float> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_nxv8f32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x float>, <vscale x 4 x float> } @llvm.vector.deinterleave2.nxv8f32(<vscale x 8 x float> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x float>, <vscale x 4 x float> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_nxv8f32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 4 x float>, <vscale x 4 x float> } @llvm.vector.deinterleave2.nxv8f32(<vscale x 8 x float> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x float>, <vscale x 4 x float> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_nxv8f32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call { <vscale x 4 x float>, <vscale x 4 x float> } @llvm.vector.deinterleave2.nxv8f32(<vscale x 8 x float> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x float>, <vscale x 4 x float> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_nxv8f32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %res = call { <vscale x 4 x float>, <vscale x 4 x float> } @llvm.vector.deinterleave2.nxv8f32(<vscale x 8 x float> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 4 x float>, <vscale x 4 x float> } %res
 ;
   %res = call { <vscale x 4 x float>, <vscale x 4 x float> } @llvm.vector.deinterleave2.nxv8f32(<vscale x 8 x float> %v)
   ret { <vscale x 4 x float>, <vscale x 4 x float> } %res
 }
 
 define { <vscale x 8 x i32>, <vscale x 8 x i32> } @deinterleave2_intrinsic_nxv16i32(<vscale x 16 x i32> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_nxv16i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 8 x i32>, <vscale x 8 x i32> } @llvm.vector.deinterleave2.nxv16i32(<vscale x 16 x i32> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i32>, <vscale x 8 x i32> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_nxv16i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 8 x i32>, <vscale x 8 x i32> } @llvm.vector.deinterleave2.nxv16i32(<vscale x 16 x i32> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i32>, <vscale x 8 x i32> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_nxv16i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 8 x i32>, <vscale x 8 x i32> } @llvm.vector.deinterleave2.nxv16i32(<vscale x 16 x i32> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i32>, <vscale x 8 x i32> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_nxv16i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %res = call { <vscale x 8 x i32>, <vscale x 8 x i32> } @llvm.vector.deinterleave2.nxv16i32(<vscale x 16 x i32> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i32>, <vscale x 8 x i32> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_nxv16i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %res = call { <vscale x 8 x i32>, <vscale x 8 x i32> } @llvm.vector.deinterleave2.nxv16i32(<vscale x 16 x i32> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i32>, <vscale x 8 x i32> } %res
 ;
   %res = call { <vscale x 8 x i32>, <vscale x 8 x i32> } @llvm.vector.deinterleave2.nxv16i32(<vscale x 16 x i32> %v)
   ret { <vscale x 8 x i32>, <vscale x 8 x i32> } %res
 }
 
 define { <vscale x 8 x i64>, <vscale x 8 x i64> } @deinterleave2_intrinsic_nxv16i64(<vscale x 16 x i64> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_nxv16i64'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 8 x i64>, <vscale x 8 x i64> } @llvm.vector.deinterleave2.nxv16i64(<vscale x 16 x i64> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i64>, <vscale x 8 x i64> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_nxv16i64'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 8 x i64>, <vscale x 8 x i64> } @llvm.vector.deinterleave2.nxv16i64(<vscale x 16 x i64> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i64>, <vscale x 8 x i64> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_nxv16i64'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 8 x i64>, <vscale x 8 x i64> } @llvm.vector.deinterleave2.nxv16i64(<vscale x 16 x i64> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i64>, <vscale x 8 x i64> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_nxv16i64'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %res = call { <vscale x 8 x i64>, <vscale x 8 x i64> } @llvm.vector.deinterleave2.nxv16i64(<vscale x 16 x i64> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i64>, <vscale x 8 x i64> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_nxv16i64'
+; ZVE32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 8 x i64>, <vscale x 8 x i64> } @llvm.vector.deinterleave2.nxv16i64(<vscale x 16 x i64> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 8 x i64>, <vscale x 8 x i64> } %res
 ;
   %res = call { <vscale x 8 x i64>, <vscale x 8 x i64> } @llvm.vector.deinterleave2.nxv16i64(<vscale x 16 x i64> %v)
   ret { <vscale x 8 x i64>, <vscale x 8 x i64> } %res
 }
 
 define { <vscale x 16 x i32>, <vscale x 16 x i32> } @deinterleave2_intrinsic_nxv32i32(<vscale x 32 x i32> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_nxv32i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 16 x i32>, <vscale x 16 x i32> } @llvm.vector.deinterleave2.nxv32i32(<vscale x 32 x i32> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 16 x i32>, <vscale x 16 x i32> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_nxv32i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 16 x i32>, <vscale x 16 x i32> } @llvm.vector.deinterleave2.nxv32i32(<vscale x 32 x i32> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 16 x i32>, <vscale x 16 x i32> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_nxv32i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 16 x i32>, <vscale x 16 x i32> } @llvm.vector.deinterleave2.nxv32i32(<vscale x 32 x i32> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 16 x i32>, <vscale x 16 x i32> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_nxv32i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %res = call { <vscale x 16 x i32>, <vscale x 16 x i32> } @llvm.vector.deinterleave2.nxv32i32(<vscale x 32 x i32> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 16 x i32>, <vscale x 16 x i32> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_nxv32i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %res = call { <vscale x 16 x i32>, <vscale x 16 x i32> } @llvm.vector.deinterleave2.nxv32i32(<vscale x 32 x i32> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 16 x i32>, <vscale x 16 x i32> } %res
 ;
   %res = call { <vscale x 16 x i32>, <vscale x 16 x i32> } @llvm.vector.deinterleave2.nxv32i32(<vscale x 32 x i32> %v)
   ret { <vscale x 16 x i32>, <vscale x 16 x i32> } %res
 }
 
 define { <vscale x 32 x i32>, <vscale x 32 x i32> } @deinterleave2_intrinsic_nxv64i32(<vscale x 64 x i32> %v) {
-; CHECK-LABEL: 'deinterleave2_intrinsic_nxv64i32'
-; CHECK-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 32 x i32>, <vscale x 32 x i32> } @llvm.vector.deinterleave2.nxv64i32(<vscale x 64 x i32> %v)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 32 x i32>, <vscale x 32 x i32> } %res
+; RV32-LABEL: 'deinterleave2_intrinsic_nxv64i32'
+; RV32-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 32 x i32>, <vscale x 32 x i32> } @llvm.vector.deinterleave2.nxv64i32(<vscale x 64 x i32> %v)
+; RV32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 32 x i32>, <vscale x 32 x i32> } %res
+;
+; RV64-LABEL: 'deinterleave2_intrinsic_nxv64i32'
+; RV64-NEXT:  Cost Model: Invalid cost for instruction: %res = call { <vscale x 32 x i32>, <vscale x 32 x i32> } @llvm.vector.deinterleave2.nxv64i32(<vscale x 64 x i32> %v)
+; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 32 x i32>, <vscale x 32 x i32> } %res
+;
+; ZVZIP-LABEL: 'deinterleave2_intrinsic_nxv64i32'
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 64 for instruction: %res = call { <vscale x 32 x i32>, <vscale x 32 x i32> } @llvm.vector.deinterleave2.nxv64i32(<vscale x 64 x i32> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 32 x i32>, <vscale x 32 x i32> } %res
+;
+; ZVE32-LABEL: 'deinterleave2_intrinsic_nxv64i32'
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 64 for instruction: %res = call { <vscale x 32 x i32>, <vscale x 32 x i32> } @llvm.vector.deinterleave2.nxv64i32(<vscale x 64 x i32> %v)
+; ZVE32-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <vscale x 32 x i32>, <vscale x 32 x i32> } %res
 ;
   %res = call { <vscale x 32 x i32>, <vscale x 32 x i32> } @llvm.vector.deinterleave2.nxv64i32(<vscale x 64 x i32> %v)
   ret { <vscale x 32 x i32>, <vscale x 32 x i32> } %res

>From 18f2ad7b6927daff959c27a2d0cab623b9c3fef3 Mon Sep 17 00:00:00 2001
From: Mingliang Liu <liumingliang.dev at bytedance.com>
Date: Thu, 24 Sep 2026 13:19:53 +0800
Subject: [PATCH 3/3] [RISCV] Make static function as the methods in
 RISCVTTIImpl

---
 .../Target/RISCV/RISCVTargetTransformInfo.cpp | 25 +++++++------------
 .../Target/RISCV/RISCVTargetTransformInfo.h   |  8 ++++++
 .../CostModel/RISCV/shuffle-interleave.ll     |  8 +++---
 3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 7102bfe724a728..3611cd1cb1e628 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -733,18 +733,14 @@ InstructionCost RISCVTTIImpl::getSlideCost(FixedVectorType *Tp,
   return FirstSlideCost + SecondSlideCost + MaskCost;
 }
 
-/// Return the type used to cost vzip.vv, whose LMUL represents the
-/// interleaved destination EMUL. Return std::nullopt if illegal.
-static std::optional<MVT> getZvzipVZIPCostVT(MVT InterleavedVT,
-                                             const RISCVSubtarget &ST,
-                                             const RISCVTargetLowering &TLI) {
+std::optional<MVT> RISCVTTIImpl::getZvzipVZIPCostVT(MVT InterleavedVT) const {
   if (!InterleavedVT.getVectorElementCount().isKnownEven())
     return std::nullopt;
 
   MVT CostVT = InterleavedVT;
   if (InterleavedVT.isFixedLengthVector()) {
     MVT SourceVT = InterleavedVT.getHalfNumVectorElementsVT();
-    CostVT = TLI.getContainerForFixedLengthVector(SourceVT)
+    CostVT = TLI->getContainerForFixedLengthVector(SourceVT)
                  .getDoubleNumVectorElementsVT();
   }
 
@@ -752,15 +748,13 @@ static std::optional<MVT> getZvzipVZIPCostVT(MVT InterleavedVT,
   unsigned MinSize = CostVT.getSizeInBits().getKnownMinValue();
   unsigned LMULOctuple = MinSize / (RISCV::RVVBitsPerBlock / 8);
   // Perform the 2 * SEW <= LMUL * min(ELEN, VLEN) check.
-  if (EltBits * 16 > LMULOctuple * std::min(ST.getELen(), ST.getRealMinVLen()))
+  if (EltBits * 16 >
+      LMULOctuple * std::min(ST->getELen(), ST->getRealMinVLen()))
     return std::nullopt;
   return CostVT;
 }
 
-/// Return the type used to cost vunzipe.v/vunzipo.v, whose LMUL represents
-/// the interleaved source EMUL. Return std::nullopt if illegal.
-static std::optional<MVT> getZvzipVUNZIPCostVT(MVT InterleavedVT,
-                                               const RISCVTargetLowering &TLI) {
+std::optional<MVT> RISCVTTIImpl::getZvzipVUNZIPCostVT(MVT InterleavedVT) const {
   if (!InterleavedVT.getVectorElementCount().isKnownEven())
     return std::nullopt;
 
@@ -769,9 +763,9 @@ static std::optional<MVT> getZvzipVUNZIPCostVT(MVT InterleavedVT,
   // an illegal result type. Apply the same rule here so the cost uses the
   // source LMUL selected by ISel.
   if (InterleavedVT.isFixedLengthVector()) {
-    CostVT = TLI.getContainerForFixedLengthVector(InterleavedVT);
+    CostVT = TLI->getContainerForFixedLengthVector(InterleavedVT);
     if (CostVT.getVectorMinNumElements() == 1 ||
-        !TLI.isTypeLegal(CostVT.getHalfNumVectorElementsVT()))
+        !TLI->isTypeLegal(CostVT.getHalfNumVectorElementsVT()))
       CostVT = CostVT.getDoubleNumVectorElementsVT();
   }
 
@@ -1982,11 +1976,10 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
     if (!LT.second.isScalableVector())
       break;
     if (IsInterleave) {
-      if (std::optional<MVT> CostVT = getZvzipVZIPCostVT(LT.second, *ST, *TLI))
+      if (std::optional<MVT> CostVT = getZvzipVZIPCostVT(LT.second))
         return LT.first *
                getRISCVInstructionCost(RISCV::VZIP_VV, *CostVT, CostKind);
-    } else if (std::optional<MVT> CostVT =
-                   getZvzipVUNZIPCostVT(LT.second, *TLI)) {
+    } else if (std::optional<MVT> CostVT = getZvzipVUNZIPCostVT(LT.second)) {
       return LT.first *
              getRISCVInstructionCost({RISCV::VUNZIPE_V, RISCV::VUNZIPO_V},
                                      *CostVT, CostKind);
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
index d6e904c53dc70d..7496297190b9f5 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
@@ -72,6 +72,14 @@ class RISCVTTIImpl final : public BasicTTIImplBase<RISCVTTIImpl> {
   InstructionCost getSlideCost(FixedVectorType *Tp, ArrayRef<int> Mask,
                                TTI::TargetCostKind CostKind) const;
 
+  /// Return the type used to cost vzip.vv, whose LMUL represents the
+  /// interleaved destination EMUL. Return std::nullopt if illegal.
+  std::optional<MVT> getZvzipVZIPCostVT(MVT InterleavedVT) const;
+
+  /// Return the type used to cost vunzipe.v/vunzipo.v, whose LMUL represents
+  /// the interleaved source EMUL. Return std::nullopt if illegal.
+  std::optional<MVT> getZvzipVUNZIPCostVT(MVT InterleavedVT) const;
+
 public:
   explicit RISCVTTIImpl(const RISCVTargetMachine *TM, const Function &F)
       : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
diff --git a/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll b/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll
index 9cf20debf3ef78..07a10e9f2e4dc5 100644
--- a/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll
+++ b/llvm/test/Analysis/CostModel/RISCV/shuffle-interleave.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+v | FileCheck --check-prefixes=CHECK,RV32 %s
 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v | FileCheck --check-prefixes=CHECK,RV64 %s
-; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+v,+zvfh,+experimental-zvzip  | FileCheck --check-prefixes=CHECK,ZVZIP %s
+; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v,+zvfh,+experimental-zvzip  | FileCheck --check-prefixes=CHECK,ZVZIP %s
 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+zve32f,+zvfh,+zvl128b,+experimental-zvzip | FileCheck --check-prefixes=CHECK,ZVE32 %s
 
 ; The mask here interleaves (%v1, %v0), not (%v0, %v1): it should still be cheap.
@@ -67,7 +67,7 @@ define <8 x i64> @interleave2_v8i64(<4 x i64> %v0, <4 x i64> %v1) {
 ;
 ; ZVZIP-LABEL: 'interleave2_v8i64'
 ; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %concat = shufflevector <4 x i64> %v0, <4 x i64> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
-; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 19 for instruction: %res = shufflevector <8 x i64> %concat, <8 x i64> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 22 for instruction: %res = shufflevector <8 x i64> %concat, <8 x i64> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
 ; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i64> %res
 ;
 ; ZVE32-LABEL: 'interleave2_v8i64'
@@ -684,7 +684,7 @@ define { <2 x i64>, <2 x i64> } @deinterleave2_intrinsic_v4i64(<4 x i64> %v) {
 ; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i64>, <2 x i64> } %res
 ;
 ; ZVZIP-LABEL: 'deinterleave2_intrinsic_v4i64'
-; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 14 for instruction: %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %res = call { <2 x i64>, <2 x i64> } @llvm.vector.deinterleave2.v4i64(<4 x i64> %v)
 ; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <2 x i64>, <2 x i64> } %res
 ;
 ; ZVE32-LABEL: 'deinterleave2_intrinsic_v4i64'
@@ -747,7 +747,7 @@ define { <4 x i64>, <4 x i64> } @deinterleave2_intrinsic_v8i64(<8 x i64> %v) {
 ; RV64-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i64>, <4 x i64> } %res
 ;
 ; ZVZIP-LABEL: 'deinterleave2_intrinsic_v8i64'
-; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 38 for instruction: %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
+; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 44 for instruction: %res = call { <4 x i64>, <4 x i64> } @llvm.vector.deinterleave2.v8i64(<8 x i64> %v)
 ; ZVZIP-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i64>, <4 x i64> } %res
 ;
 ; ZVE32-LABEL: 'deinterleave2_intrinsic_v8i64'



More information about the llvm-commits mailing list