[llvm] [GlobalISel] Remove references to rhs of shufflevector if rhs is undef (PR #115076)
Konstantin Schwarz via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 6 16:12:24 PST 2024
https://github.com/konstantinschwarz updated https://github.com/llvm/llvm-project/pull/115076
>From 3534945344173c39fa59899e3bcb540eaafa2b90 Mon Sep 17 00:00:00 2001
From: Konstantin Schwarz <konstantin.schwarz at amd.com>
Date: Tue, 5 Nov 2024 20:31:52 +0000
Subject: [PATCH] [GlobalISel] Remove references to rhs of shufflevector if rhs
is undef
---
.../llvm/CodeGen/GlobalISel/CombinerHelper.h | 4 +
.../include/llvm/Target/GlobalISel/Combine.td | 13 +-
.../lib/CodeGen/GlobalISel/CombinerHelper.cpp | 30 ++
.../CodeGen/GlobalISel/MachineIRBuilder.cpp | 14 +-
...lizercombiner-shuffle-vector-undef-rhs.mir | 42 ++
llvm/test/CodeGen/AArch64/neon-perm.ll | 360 +++++-------------
6 files changed, 200 insertions(+), 263 deletions(-)
create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-shuffle-vector-undef-rhs.mir
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
index 9240a3c3127eb4..72573facf1a7fe 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
@@ -867,6 +867,10 @@ class CombinerHelper {
/// register and different indices.
bool matchExtractVectorElementWithDifferentIndices(const MachineOperand &MO,
BuildFnTy &MatchInfo);
+
+ /// Remove references to rhs if it is undef
+ bool matchShuffleUndefRHS(MachineInstr &MI, BuildFnTy &MatchInfo);
+
/// Use a function which takes in a MachineIRBuilder to perform a combine.
/// By default, it erases the instruction def'd on \p MO from the function.
void applyBuildFnMO(const MachineOperand &MO, BuildFnTy &MatchInfo);
diff --git a/llvm/include/llvm/Target/GlobalISel/Combine.td b/llvm/include/llvm/Target/GlobalISel/Combine.td
index ead4149fc11068..b98369c8cfc638 100644
--- a/llvm/include/llvm/Target/GlobalISel/Combine.td
+++ b/llvm/include/llvm/Target/GlobalISel/Combine.td
@@ -1568,6 +1568,14 @@ def expand_const_fpowi : GICombineRule<
[{ return Helper.matchFPowIExpansion(*${root}, ${imm}.getCImm()->getSExtValue()); }]),
(apply [{ Helper.applyExpandFPowI(*${root}, ${imm}.getCImm()->getSExtValue()); }])>;
+def combine_shuffle_undef_rhs : GICombineRule<
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
+ (match (G_IMPLICIT_DEF $undef),
+ (G_SHUFFLE_VECTOR $root, $src1, $undef, $mask):$root,
+ [{ return Helper.matchShuffleUndefRHS(*${root}, ${matchinfo}); }]),
+ (apply [{ Helper.applyBuildFn(*${root}, ${matchinfo}); }])
+>;
+
// match_extract_of_element and insert_vector_elt_oob must be the first!
def vector_ops_combines: GICombineGroup<[
match_extract_of_element_undef_vector,
@@ -1917,6 +1925,9 @@ def constant_fold_binops : GICombineGroup<[constant_fold_binop,
def prefer_sign_combines : GICombineGroup<[nneg_zext]>;
+def shuffle_combines : GICombineGroup<[combine_shuffle_concat,
+ combine_shuffle_undef_rhs]>;
+
def all_combines : GICombineGroup<[integer_reassoc_combines, trivial_combines,
vector_ops_combines, freeze_combines, cast_combines,
insert_vec_elt_combines, extract_vec_elt_combines, combines_for_extload,
@@ -1938,7 +1949,7 @@ def all_combines : GICombineGroup<[integer_reassoc_combines, trivial_combines,
sub_add_reg, select_to_minmax,
fsub_to_fneg, commute_constant_to_rhs, match_ands, match_ors,
combine_concat_vector, match_addos,
- sext_trunc, zext_trunc, prefer_sign_combines, combine_shuffle_concat,
+ sext_trunc, zext_trunc, prefer_sign_combines, shuffle_combines,
combine_use_vector_truncate, merge_combines]>;
// A combine group used to for prelegalizer combiners at -O0. The combines in
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index 1f2baa3fa9c0f8..3b648a7e3f4472 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -7696,3 +7696,33 @@ bool CombinerHelper::matchUnmergeValuesAnyExtBuildVector(const MachineInstr &MI,
return false;
}
+
+bool CombinerHelper::matchShuffleUndefRHS(MachineInstr &MI,
+ BuildFnTy &MatchInfo) {
+
+ bool Changed = false;
+ auto &Shuffle = cast<GShuffleVector>(MI);
+ ArrayRef<int> OrigMask = Shuffle.getMask();
+ SmallVector<int, 16> NewMask;
+ const LLT SrcTy = MRI.getType(Shuffle.getSrc1Reg());
+ const unsigned NumSrcElems = SrcTy.isVector() ? SrcTy.getNumElements() : 1;
+ const unsigned NumDstElts = OrigMask.size();
+ for (unsigned i = 0; i != NumDstElts; ++i) {
+ int Idx = OrigMask[i];
+ if (Idx >= (int)NumSrcElems) {
+ Idx = -1;
+ Changed = true;
+ }
+ NewMask.push_back(Idx);
+ }
+
+ if (!Changed)
+ return false;
+
+ MatchInfo = [&, NewMask](MachineIRBuilder &B) {
+ B.buildShuffleVector(MI.getOperand(0), MI.getOperand(1), MI.getOperand(2),
+ NewMask);
+ };
+
+ return true;
+}
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
index 15b9164247846c..02dbe781babdba 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
@@ -772,13 +772,13 @@ MachineInstrBuilder MachineIRBuilder::buildShuffleVector(const DstOp &Res,
LLT DstTy = Res.getLLTTy(*getMRI());
LLT Src1Ty = Src1.getLLTTy(*getMRI());
LLT Src2Ty = Src2.getLLTTy(*getMRI());
- assert((size_t)(Src1Ty.getNumElements() + Src2Ty.getNumElements()) >=
- Mask.size());
- assert(DstTy.getElementType() == Src1Ty.getElementType() &&
- DstTy.getElementType() == Src2Ty.getElementType());
- (void)DstTy;
- (void)Src1Ty;
- (void)Src2Ty;
+ const LLT DstElemTy = DstTy.isVector() ? DstTy.getElementType() : DstTy;
+ const LLT ElemTy1 = Src1Ty.isVector() ? Src1Ty.getElementType() : Src1Ty;
+ const LLT ElemTy2 = Src2Ty.isVector() ? Src2Ty.getElementType() : Src2Ty;
+ assert(DstElemTy == ElemTy1 && DstElemTy == ElemTy2);
+ (void)DstElemTy;
+ (void)ElemTy1;
+ (void)ElemTy2;
ArrayRef<int> MaskAlloc = getMF().allocateShuffleMask(Mask);
return buildInstr(TargetOpcode::G_SHUFFLE_VECTOR, {Res}, {Src1, Src2})
.addShuffleMask(MaskAlloc);
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-shuffle-vector-undef-rhs.mir b/llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-shuffle-vector-undef-rhs.mir
new file mode 100644
index 00000000000000..9bf79936463c32
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-shuffle-vector-undef-rhs.mir
@@ -0,0 +1,42 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
+
+---
+name: shuffle_vector_undef_rhs
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $d0
+
+ ; CHECK-LABEL: name: shuffle_vector_undef_rhs
+ ; CHECK: liveins: $d0
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
+ ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<2 x s32>) = G_IMPLICIT_DEF
+ ; CHECK-NEXT: [[SHUF:%[0-9]+]]:_(<4 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<2 x s32>), [[DEF]], shufflemask(0, undef, 1, undef)
+ ; CHECK-NEXT: RET_ReallyLR implicit [[SHUF]](<4 x s32>)
+ %0:_(<2 x s32>) = COPY $d0
+ %1:_(<2 x s32>) = G_IMPLICIT_DEF
+ %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1(<2 x s32>), shufflemask(0, 2, 1, 3)
+ RET_ReallyLR implicit %2
+...
+
+---
+name: shuffle_vector_undef_rhs_scalar
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $x0
+
+ ; CHECK-LABEL: name: shuffle_vector_undef_rhs_scalar
+ ; CHECK: liveins: $x0
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+ ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
+ ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s64>) = G_BUILD_VECTOR [[COPY]](s64), [[DEF]](s64)
+ ; CHECK-NEXT: RET_ReallyLR implicit [[BUILD_VECTOR]](<2 x s64>)
+ %0:_(s64) = COPY $x0
+ %1:_(s64) = G_IMPLICIT_DEF
+ %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(s64), %1(s64), shufflemask(0, 1)
+ RET_ReallyLR implicit %2
+...
diff --git a/llvm/test/CodeGen/AArch64/neon-perm.ll b/llvm/test/CodeGen/AArch64/neon-perm.ll
index 7b85924ce1e323..ad036218f242ca 100644
--- a/llvm/test/CodeGen/AArch64/neon-perm.ll
+++ b/llvm/test/CodeGen/AArch64/neon-perm.ll
@@ -2838,435 +2838,285 @@ entry:
}
define <8 x i8> @test_undef_vtrn1_s8(<8 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1_s8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1_s8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.8b, v0.8b, v0.8b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1_s8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i8> %a, <8 x i8> undef, <8 x i32> <i32 0, i32 8, i32 2, i32 10, i32 4, i32 12, i32 6, i32 14>
ret <8 x i8> %shuffle.i
}
define <16 x i8> @test_undef_vtrn1q_s8(<16 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1q_s8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1q_s8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.16b, v0.16b, v0.16b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1q_s8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> <i32 0, i32 16, i32 2, i32 18, i32 4, i32 20, i32 6, i32 22, i32 8, i32 24, i32 10, i32 26, i32 12, i32 28, i32 14, i32 30>
ret <16 x i8> %shuffle.i
}
define <4 x i16> @test_undef_vtrn1_s16(<4 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1_s16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1_s16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.4h, v0.4h, v0.4h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1_s16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x i16> %a, <4 x i16> undef, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
ret <4 x i16> %shuffle.i
}
define <8 x i16> @test_undef_vtrn1q_s16(<8 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1q_s16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1q_s16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.8h, v0.8h, v0.8h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1q_s16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 0, i32 8, i32 2, i32 10, i32 4, i32 12, i32 6, i32 14>
ret <8 x i16> %shuffle.i
}
define <4 x i32> @test_undef_vtrn1q_s32(<4 x i32> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1q_s32:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1q_s32:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.4s, v0.4s, v0.4s
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1q_s32:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
ret <4 x i32> %shuffle.i
}
define <8 x i8> @test_undef_vtrn1_u8(<8 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1_u8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1_u8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.8b, v0.8b, v0.8b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1_u8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i8> %a, <8 x i8> undef, <8 x i32> <i32 0, i32 8, i32 2, i32 10, i32 4, i32 12, i32 6, i32 14>
ret <8 x i8> %shuffle.i
}
define <16 x i8> @test_undef_vtrn1q_u8(<16 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1q_u8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1q_u8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.16b, v0.16b, v0.16b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1q_u8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> <i32 0, i32 16, i32 2, i32 18, i32 4, i32 20, i32 6, i32 22, i32 8, i32 24, i32 10, i32 26, i32 12, i32 28, i32 14, i32 30>
ret <16 x i8> %shuffle.i
}
define <4 x i16> @test_undef_vtrn1_u16(<4 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1_u16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1_u16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.4h, v0.4h, v0.4h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1_u16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x i16> %a, <4 x i16> undef, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
ret <4 x i16> %shuffle.i
}
define <8 x i16> @test_undef_vtrn1q_u16(<8 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1q_u16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1q_u16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.8h, v0.8h, v0.8h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1q_u16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 0, i32 8, i32 2, i32 10, i32 4, i32 12, i32 6, i32 14>
ret <8 x i16> %shuffle.i
}
define <4 x i32> @test_undef_vtrn1q_u32(<4 x i32> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1q_u32:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1q_u32:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.4s, v0.4s, v0.4s
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1q_u32:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
ret <4 x i32> %shuffle.i
}
define <4 x float> @test_undef_vtrn1q_f32(<4 x float> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1q_f32:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1q_f32:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.4s, v0.4s, v0.4s
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1q_f32:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
ret <4 x float> %shuffle.i
}
define <8 x i8> @test_undef_vtrn1_p8(<8 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1_p8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1_p8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.8b, v0.8b, v0.8b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1_p8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i8> %a, <8 x i8> undef, <8 x i32> <i32 0, i32 8, i32 2, i32 10, i32 4, i32 12, i32 6, i32 14>
ret <8 x i8> %shuffle.i
}
define <16 x i8> @test_undef_vtrn1q_p8(<16 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1q_p8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1q_p8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.16b, v0.16b, v0.16b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1q_p8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> <i32 0, i32 16, i32 2, i32 18, i32 4, i32 20, i32 6, i32 22, i32 8, i32 24, i32 10, i32 26, i32 12, i32 28, i32 14, i32 30>
ret <16 x i8> %shuffle.i
}
define <4 x i16> @test_undef_vtrn1_p16(<4 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1_p16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1_p16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.4h, v0.4h, v0.4h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1_p16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x i16> %a, <4 x i16> undef, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
ret <4 x i16> %shuffle.i
}
define <8 x i16> @test_undef_vtrn1q_p16(<8 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn1q_p16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn1q_p16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn1 v0.8h, v0.8h, v0.8h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn1q_p16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 0, i32 8, i32 2, i32 10, i32 4, i32 12, i32 6, i32 14>
ret <8 x i16> %shuffle.i
}
define <8 x i8> @test_undef_vtrn2_s8(<8 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2_s8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev16 v0.8b, v0.8b
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2_s8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.8b, v0.8b, v0.8b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2_s8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev16 v0.8b, v0.8b
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i8> %a, <8 x i8> undef, <8 x i32> <i32 1, i32 9, i32 3, i32 11, i32 5, i32 13, i32 7, i32 15>
ret <8 x i8> %shuffle.i
}
define <16 x i8> @test_undef_vtrn2q_s8(<16 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2q_s8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev16 v0.16b, v0.16b
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2q_s8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.16b, v0.16b, v0.16b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2q_s8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev16 v0.16b, v0.16b
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> <i32 1, i32 17, i32 3, i32 19, i32 5, i32 21, i32 7, i32 23, i32 9, i32 25, i32 11, i32 27, i32 13, i32 29, i32 15, i32 31>
ret <16 x i8> %shuffle.i
}
define <4 x i16> @test_undef_vtrn2_s16(<4 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2_s16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev32 v0.4h, v0.4h
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2_s16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.4h, v0.4h, v0.4h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2_s16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev32 v0.4h, v0.4h
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x i16> %a, <4 x i16> undef, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
ret <4 x i16> %shuffle.i
}
define <8 x i16> @test_undef_vtrn2q_s16(<8 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2q_s16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev32 v0.8h, v0.8h
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2q_s16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.8h, v0.8h, v0.8h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2q_s16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev32 v0.8h, v0.8h
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 1, i32 9, i32 3, i32 11, i32 5, i32 13, i32 7, i32 15>
ret <8 x i16> %shuffle.i
}
define <4 x i32> @test_undef_vtrn2q_s32(<4 x i32> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2q_s32:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev64 v0.4s, v0.4s
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2q_s32:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.4s, v0.4s, v0.4s
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2q_s32:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev64 v0.4s, v0.4s
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
ret <4 x i32> %shuffle.i
}
define <8 x i8> @test_undef_vtrn2_u8(<8 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2_u8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev16 v0.8b, v0.8b
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2_u8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.8b, v0.8b, v0.8b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2_u8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev16 v0.8b, v0.8b
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i8> %a, <8 x i8> undef, <8 x i32> <i32 1, i32 9, i32 3, i32 11, i32 5, i32 13, i32 7, i32 15>
ret <8 x i8> %shuffle.i
}
define <16 x i8> @test_undef_vtrn2q_u8(<16 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2q_u8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev16 v0.16b, v0.16b
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2q_u8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.16b, v0.16b, v0.16b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2q_u8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev16 v0.16b, v0.16b
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> <i32 1, i32 17, i32 3, i32 19, i32 5, i32 21, i32 7, i32 23, i32 9, i32 25, i32 11, i32 27, i32 13, i32 29, i32 15, i32 31>
ret <16 x i8> %shuffle.i
}
define <4 x i16> @test_undef_vtrn2_u16(<4 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2_u16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev32 v0.4h, v0.4h
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2_u16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.4h, v0.4h, v0.4h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2_u16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev32 v0.4h, v0.4h
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x i16> %a, <4 x i16> undef, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
ret <4 x i16> %shuffle.i
}
define <8 x i16> @test_undef_vtrn2q_u16(<8 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2q_u16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev32 v0.8h, v0.8h
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2q_u16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.8h, v0.8h, v0.8h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2q_u16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev32 v0.8h, v0.8h
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 1, i32 9, i32 3, i32 11, i32 5, i32 13, i32 7, i32 15>
ret <8 x i16> %shuffle.i
}
define <4 x i32> @test_undef_vtrn2q_u32(<4 x i32> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2q_u32:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev64 v0.4s, v0.4s
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2q_u32:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.4s, v0.4s, v0.4s
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2q_u32:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev64 v0.4s, v0.4s
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
ret <4 x i32> %shuffle.i
}
define <4 x float> @test_undef_vtrn2q_f32(<4 x float> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2q_f32:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev64 v0.4s, v0.4s
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2q_f32:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.4s, v0.4s, v0.4s
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2q_f32:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev64 v0.4s, v0.4s
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
ret <4 x float> %shuffle.i
}
define <8 x i8> @test_undef_vtrn2_p8(<8 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2_p8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev16 v0.8b, v0.8b
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2_p8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.8b, v0.8b, v0.8b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2_p8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev16 v0.8b, v0.8b
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i8> %a, <8 x i8> undef, <8 x i32> <i32 1, i32 9, i32 3, i32 11, i32 5, i32 13, i32 7, i32 15>
ret <8 x i8> %shuffle.i
}
define <16 x i8> @test_undef_vtrn2q_p8(<16 x i8> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2q_p8:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev16 v0.16b, v0.16b
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2q_p8:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.16b, v0.16b, v0.16b
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2q_p8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev16 v0.16b, v0.16b
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> <i32 1, i32 17, i32 3, i32 19, i32 5, i32 21, i32 7, i32 23, i32 9, i32 25, i32 11, i32 27, i32 13, i32 29, i32 15, i32 31>
ret <16 x i8> %shuffle.i
}
define <4 x i16> @test_undef_vtrn2_p16(<4 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2_p16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev32 v0.4h, v0.4h
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2_p16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.4h, v0.4h, v0.4h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2_p16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev32 v0.4h, v0.4h
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <4 x i16> %a, <4 x i16> undef, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
ret <4 x i16> %shuffle.i
}
define <8 x i16> @test_undef_vtrn2q_p16(<8 x i16> %a) {
-; CHECK-SD-LABEL: test_undef_vtrn2q_p16:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: rev32 v0.8h, v0.8h
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: test_undef_vtrn2q_p16:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: trn2 v0.8h, v0.8h, v0.8h
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: test_undef_vtrn2q_p16:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: rev32 v0.8h, v0.8h
+; CHECK-NEXT: ret
entry:
%shuffle.i = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 1, i32 9, i32 3, i32 11, i32 5, i32 13, i32 7, i32 15>
ret <8 x i16> %shuffle.i
More information about the llvm-commits
mailing list