xref: /llvm-project/llvm/test/Transforms/InstSimplify/insert-vector.ll (revision a83aa33d1bf9e8fe4858391f95a27ffd022e465b)
12ed7db0dSJoe Ellis; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2b280ee1dSBjorn Pettersson; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
32ed7db0dSJoe Ellis
45a476987SJoe Ellisdefine <vscale x 16 x i8> @redundant_extract_insert_chain(<vscale x 16 x i8> %x) {
52ed7db0dSJoe Ellis; CHECK-LABEL: @redundant_extract_insert_chain(
62ed7db0dSJoe Ellis; CHECK-NEXT:    ret <vscale x 16 x i8> [[X:%.*]]
72ed7db0dSJoe Ellis;
8*a83aa33dSBradley Smith  %extracted = call <32 x i8> @llvm.vector.extract.v32i8.nxv16i8(<vscale x 16 x i8> %x, i64 0)
9*a83aa33dSBradley Smith  %inserted = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v32i8(<vscale x 16 x i8> undef, <32 x i8> %extracted, i64 0)
102ed7db0dSJoe Ellis  ret <vscale x 16 x i8> %inserted
112ed7db0dSJoe Ellis}
122ed7db0dSJoe Ellis
135a476987SJoe Ellisdefine <vscale x 16 x i8> @non_redundant_extract_insert_chain_0(<vscale x 32 x i8> %x) {
145a476987SJoe Ellis; CHECK-LABEL: @non_redundant_extract_insert_chain_0(
15*a83aa33dSBradley Smith; CHECK-NEXT:    [[EXTRACTED:%.*]] = call <32 x i8> @llvm.vector.extract.v32i8.nxv32i8(<vscale x 32 x i8> [[X:%.*]], i64 0)
16*a83aa33dSBradley Smith; CHECK-NEXT:    [[INSERTED:%.*]] = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v32i8(<vscale x 16 x i8> undef, <32 x i8> [[EXTRACTED]], i64 0)
172ed7db0dSJoe Ellis; CHECK-NEXT:    ret <vscale x 16 x i8> [[INSERTED]]
182ed7db0dSJoe Ellis;
19*a83aa33dSBradley Smith  %extracted = call <32 x i8> @llvm.vector.extract.v32i8.nxv32i8(<vscale x 32 x i8> %x, i64 0)
20*a83aa33dSBradley Smith  %inserted = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v32i8(<vscale x 16 x i8> undef, <32 x i8> %extracted, i64 0)
212ed7db0dSJoe Ellis  ret <vscale x 16 x i8> %inserted
222ed7db0dSJoe Ellis}
232ed7db0dSJoe Ellis
245a476987SJoe Ellisdefine <vscale x 16 x i8> @non_redundant_extract_insert_chain_1(<vscale x 16 x i8> %x, <vscale x 16 x i8> %y) {
255a476987SJoe Ellis; CHECK-LABEL: @non_redundant_extract_insert_chain_1(
26*a83aa33dSBradley Smith; CHECK-NEXT:    [[EXTRACTED:%.*]] = call <32 x i8> @llvm.vector.extract.v32i8.nxv16i8(<vscale x 16 x i8> [[X:%.*]], i64 0)
27*a83aa33dSBradley Smith; CHECK-NEXT:    [[INSERTED:%.*]] = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v32i8(<vscale x 16 x i8> [[Y:%.*]], <32 x i8> [[EXTRACTED]], i64 0)
285a476987SJoe Ellis; CHECK-NEXT:    ret <vscale x 16 x i8> [[INSERTED]]
295a476987SJoe Ellis;
30*a83aa33dSBradley Smith  %extracted = call <32 x i8> @llvm.vector.extract.v32i8.nxv16i8(<vscale x 16 x i8> %x, i64 0)
31*a83aa33dSBradley Smith  %inserted = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v32i8(<vscale x 16 x i8> %y, <32 x i8> %extracted, i64 0)
325a476987SJoe Ellis  ret <vscale x 16 x i8> %inserted
335a476987SJoe Ellis}
345a476987SJoe Ellis
35*a83aa33dSBradley Smithdeclare <32 x i8> @llvm.vector.extract.v32i8.nxv16i8(<vscale x 16 x i8>, i64)
36*a83aa33dSBradley Smithdeclare <32 x i8> @llvm.vector.extract.v32i8.nxv32i8(<vscale x 32 x i8>, i64)
37*a83aa33dSBradley Smithdeclare <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v32i8(<vscale x 16 x i8>, <32 x i8>, i64)
38