1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
| ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s
define <16 x i8> @foov16i8(<8 x i16> %a0, <8 x i16> %b0) nounwind readnone ssp {
; CHECK-LABEL: foov16i8:
%vshrn_low_shift = lshr <8 x i16> %a0, <i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5>
%vshrn_low = trunc <8 x i16> %vshrn_low_shift to <8 x i8>
%vshrn_high_shift = lshr <8 x i16> %b0, <i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5>
%vshrn_high = trunc <8 x i16> %vshrn_high_shift to <8 x i8>
; CHECK: shrn.8b v0, v0, #5
; CHECK-NEXT: shrn2.16b v0, v1, #5
; CHECK-NEXT: ret
%1 = bitcast <8 x i8> %vshrn_low to <1 x i64>
%2 = bitcast <8 x i8> %vshrn_high to <1 x i64>
%shuffle.i = shufflevector <1 x i64> %1, <1 x i64> %2, <2 x i32> <i32 0, i32 1>
%3 = bitcast <2 x i64> %shuffle.i to <16 x i8>
ret <16 x i8> %3
}
define <8 x i16> @foov8i16(<4 x i32> %a0, <4 x i32> %b0) nounwind readnone ssp {
; CHECK-LABEL: foov8i16:
%vshrn_low_shift = lshr <4 x i32> %a0, <i32 5, i32 5, i32 5, i32 5>
%vshrn_low = trunc <4 x i32> %vshrn_low_shift to <4 x i16>
%vshrn_high_shift = lshr <4 x i32> %b0, <i32 5, i32 5, i32 5, i32 5>
%vshrn_high = trunc <4 x i32> %vshrn_high_shift to <4 x i16>
; CHECK: shrn.4h v0, v0, #5
; CHECK-NEXT: shrn2.8h v0, v1, #5
; CHECK-NEXT: ret
%1 = bitcast <4 x i16> %vshrn_low to <1 x i64>
%2 = bitcast <4 x i16> %vshrn_high to <1 x i64>
%shuffle.i = shufflevector <1 x i64> %1, <1 x i64> %2, <2 x i32> <i32 0, i32 1>
%3 = bitcast <2 x i64> %shuffle.i to <8 x i16>
ret <8 x i16> %3
}
define <4 x i32> @foov4i32(<2 x i64> %a0, <2 x i64> %b0) nounwind readnone ssp {
; CHECK-LABEL: foov4i32:
%vshrn_low_shift = lshr <2 x i64> %a0, <i64 5, i64 5>
%vshrn_low = trunc <2 x i64> %vshrn_low_shift to <2 x i32>
%vshrn_high_shift = lshr <2 x i64> %b0, <i64 5, i64 5>
%vshrn_high = trunc <2 x i64> %vshrn_high_shift to <2 x i32>
; CHECK: shrn.2s v0, v0, #5
; CHECK-NEXT: shrn2.4s v0, v1, #5
; CHECK-NEXT: ret
%1 = bitcast <2 x i32> %vshrn_low to <1 x i64>
%2 = bitcast <2 x i32> %vshrn_high to <1 x i64>
%shuffle.i = shufflevector <1 x i64> %1, <1 x i64> %2, <2 x i32> <i32 0, i32 1>
%3 = bitcast <2 x i64> %shuffle.i to <4 x i32>
ret <4 x i32> %3
}
define <8 x i16> @bar(<4 x i32> %a0, <4 x i32> %a1, <4 x i32> %b0, <4 x i32> %b1) nounwind readnone ssp {
; CHECK-LABEL: bar:
%vaddhn2.i = tail call <4 x i16> @llvm.aarch64.neon.addhn.v4i16(<4 x i32> %a0, <4 x i32> %a1) nounwind
%vaddhn2.i10 = tail call <4 x i16> @llvm.aarch64.neon.addhn.v4i16(<4 x i32> %b0, <4 x i32> %b1) nounwind
; CHECK: addhn.4h v0, v0, v1
; CHECK-NEXT: addhn2.8h v0, v2, v3
; CHECK-NEXT: ret
%1 = bitcast <4 x i16> %vaddhn2.i to <1 x i64>
%2 = bitcast <4 x i16> %vaddhn2.i10 to <1 x i64>
%shuffle.i = shufflevector <1 x i64> %1, <1 x i64> %2, <2 x i32> <i32 0, i32 1>
%3 = bitcast <2 x i64> %shuffle.i to <8 x i16>
ret <8 x i16> %3
}
define <8 x i16> @baz(<4 x i32> %a0, <4 x i32> %a1, <4 x i32> %b0, <4 x i32> %b1) nounwind readnone ssp {
; CHECK-LABEL: baz:
%vaddhn2.i = tail call <4 x i16> @llvm.aarch64.neon.addhn.v4i16(<4 x i32> %a0, <4 x i32> %a1) nounwind
%vshrn_high_shift = ashr <4 x i32> %b0, <i32 5, i32 5, i32 5, i32 5>
%vshrn_high = trunc <4 x i32> %vshrn_high_shift to <4 x i16>
; CHECK: addhn.4h v0, v0, v1
; CHECK-NEXT: shrn2.8h v0, v2, #5
; CHECK-NEXT: ret
%1 = bitcast <4 x i16> %vaddhn2.i to <1 x i64>
%2 = bitcast <4 x i16> %vshrn_high to <1 x i64>
%shuffle.i = shufflevector <1 x i64> %1, <1 x i64> %2, <2 x i32> <i32 0, i32 1>
%3 = bitcast <2 x i64> %shuffle.i to <8 x i16>
ret <8 x i16> %3
}
define <8 x i16> @raddhn(<4 x i32> %a0, <4 x i32> %a1, <4 x i32> %b0, <4 x i32> %b1) nounwind readnone ssp {
; CHECK-LABEL: raddhn:
entry:
; CHECK: raddhn.4h v0, v0, v1
; CHECK-NEXT: raddhn2.8h v0, v2, v3
; CHECK-NEXT: ret
%vraddhn2.i = tail call <4 x i16> @llvm.aarch64.neon.raddhn.v4i16(<4 x i32> %a0, <4 x i32> %a1) nounwind
%vraddhn2.i10 = tail call <4 x i16> @llvm.aarch64.neon.raddhn.v4i16(<4 x i32> %b0, <4 x i32> %b1) nounwind
%0 = bitcast <4 x i16> %vraddhn2.i to <1 x i64>
%1 = bitcast <4 x i16> %vraddhn2.i10 to <1 x i64>
%shuffle.i = shufflevector <1 x i64> %0, <1 x i64> %1, <2 x i32> <i32 0, i32 1>
%2 = bitcast <2 x i64> %shuffle.i to <8 x i16>
ret <8 x i16> %2
}
define <8 x i16> @vrshrn(<8 x i16> %a0, <8 x i16> %a1, <8 x i16> %b0, <8 x i16> %b1) nounwind readnone ssp {
; CHECK-LABEL: vrshrn:
; CHECK: rshrn.8b v0, v0, #5
; CHECK-NEXT: rshrn2.16b v0, v2, #6
; CHECK-NEXT: ret
%vrshrn_n1 = tail call <8 x i8> @llvm.aarch64.neon.rshrn.v8i8(<8 x i16> %a0, i32 5)
%vrshrn_n4 = tail call <8 x i8> @llvm.aarch64.neon.rshrn.v8i8(<8 x i16> %b0, i32 6)
%1 = bitcast <8 x i8> %vrshrn_n1 to <1 x i64>
%2 = bitcast <8 x i8> %vrshrn_n4 to <1 x i64>
%shuffle.i = shufflevector <1 x i64> %1, <1 x i64> %2, <2 x i32> <i32 0, i32 1>
%3 = bitcast <2 x i64> %shuffle.i to <8 x i16>
ret <8 x i16> %3
}
define <8 x i16> @vrsubhn(<8 x i16> %a0, <8 x i16> %a1, <8 x i16> %b0, <8 x i16> %b1) nounwind readnone ssp {
; CHECK-LABEL: vrsubhn:
; CHECK: rsubhn.8b v0, v0, v1
; CHECK: rsubhn2.16b v0, v2, v3
; CHECK-NEXT: ret
%vrsubhn2.i = tail call <8 x i8> @llvm.aarch64.neon.rsubhn.v8i8(<8 x i16> %a0, <8 x i16> %a1) nounwind
%vrsubhn2.i10 = tail call <8 x i8> @llvm.aarch64.neon.rsubhn.v8i8(<8 x i16> %b0, <8 x i16> %b1) nounwind
%1 = bitcast <8 x i8> %vrsubhn2.i to <1 x i64>
%2 = bitcast <8 x i8> %vrsubhn2.i10 to <1 x i64>
%shuffle.i = shufflevector <1 x i64> %1, <1 x i64> %2, <2 x i32> <i32 0, i32 1>
%3 = bitcast <2 x i64> %shuffle.i to <8 x i16>
ret <8 x i16> %3
}
define <8 x i16> @noOpt1(<2 x i32> %a0, <2 x i32> %a1, <4 x i32> %b0, <4 x i32> %b1) nounwind readnone ssp {
; CHECK-LABEL: noOpt1:
%vqsub2.i = tail call <2 x i32> @llvm.aarch64.neon.sqsub.v2i32(<2 x i32> %a0, <2 x i32> %a1) nounwind
%vaddhn2.i = tail call <4 x i16> @llvm.aarch64.neon.addhn.v4i16(<4 x i32> %b0, <4 x i32> %b1) nounwind
; CHECK: sqsub.2s v0, v0, v1
; CHECK-NEXT: addhn2.8h v0, v2, v3
%1 = bitcast <2 x i32> %vqsub2.i to <1 x i64>
%2 = bitcast <4 x i16> %vaddhn2.i to <1 x i64>
%shuffle.i = shufflevector <1 x i64> %1, <1 x i64> %2, <2 x i32> <i32 0, i32 1>
%3 = bitcast <2 x i64> %shuffle.i to <8 x i16>
ret <8 x i16> %3
}
declare <2 x i32> @llvm.aarch64.neon.sqsub.v2i32(<2 x i32>, <2 x i32>) nounwind readnone
declare <8 x i8> @llvm.aarch64.neon.shrn.v8i8(<8 x i16>, i32) nounwind readnone
declare <4 x i16> @llvm.aarch64.neon.shrn.v4i16(<4 x i32>, i32) nounwind readnone
declare <2 x i32> @llvm.aarch64.neon.shrn.v2i32(<2 x i64>, i32) nounwind readnone
declare <4 x i16> @llvm.aarch64.neon.addhn.v4i16(<4 x i32>, <4 x i32>) nounwind readnone
declare <4 x i16> @llvm.aarch64.neon.raddhn.v4i16(<4 x i32>, <4 x i32>) nounwind readnone
declare <8 x i8> @llvm.aarch64.neon.rshrn.v8i8(<8 x i16>, i32) nounwind readnone
declare <8 x i8> @llvm.aarch64.neon.rsubhn.v8i8(<8 x i16>, <8 x i16>) nounwind readnone
|