Skip to content

Commit d38a025

Browse files
committed
[AArch64] Add patterns for FMCLA*_indexed.
This patch adds patterns for the indexed variants of FCMLA. Mostly based on a patch by Tim Northover. Reviewed By: SjoerdMeijer Differential Revision: https://reviews.llvm.org/D92947
1 parent 23b4198 commit d38a025

2 files changed

Lines changed: 116 additions & 0 deletions

File tree

‎llvm/lib/Target/AArch64/AArch64InstrInfo.td‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in {
951951
def : Pat<(v8f16 (int_aarch64_neon_vcadd_rot270 (v8f16 V128:$Rn), (v8f16 V128:$Rm))),
952952
(FCADDv8f16 (v8f16 V128:$Rn), (v8f16 V128:$Rm), (i32 1))>;
953953
}
954+
954955
let Predicates = [HasComplxNum, HasNEON] in {
955956
def : Pat<(v2f32 (int_aarch64_neon_vcadd_rot90 (v2f32 V64:$Rn), (v2f32 V64:$Rm))),
956957
(FCADDv2f32 (v2f32 V64:$Rn), (v2f32 V64:$Rm), (i32 0))>;
@@ -975,14 +976,34 @@ multiclass FCMLA_PATS<ValueType ty, RegisterClass Reg> {
975976
(!cast<Instruction>("FCMLA" # ty) $Rd, $Rn, $Rm, 3)>;
976977
}
977978

979+
multiclass FCMLA_LANE_PATS<ValueType ty, RegisterClass Reg, dag RHSDup> {
980+
def : Pat<(ty (int_aarch64_neon_vcmla_rot0 (ty Reg:$Rd), (ty Reg:$Rn), RHSDup)),
981+
(!cast<Instruction>("FCMLA" # ty # "_indexed") $Rd, $Rn, $Rm, VectorIndexS:$idx, 0)>;
982+
def : Pat<(ty (int_aarch64_neon_vcmla_rot90 (ty Reg:$Rd), (ty Reg:$Rn), RHSDup)),
983+
(!cast<Instruction>("FCMLA" # ty # "_indexed") $Rd, $Rn, $Rm, VectorIndexS:$idx, 1)>;
984+
def : Pat<(ty (int_aarch64_neon_vcmla_rot180 (ty Reg:$Rd), (ty Reg:$Rn), RHSDup)),
985+
(!cast<Instruction>("FCMLA" # ty # "_indexed") $Rd, $Rn, $Rm, VectorIndexS:$idx, 2)>;
986+
def : Pat<(ty (int_aarch64_neon_vcmla_rot270 (ty Reg:$Rd), (ty Reg:$Rn), RHSDup)),
987+
(!cast<Instruction>("FCMLA" # ty # "_indexed") $Rd, $Rn, $Rm, VectorIndexS:$idx, 3)>;
988+
}
989+
990+
978991
let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in {
979992
defm : FCMLA_PATS<v4f16, V64>;
980993
defm : FCMLA_PATS<v8f16, V128>;
994+
995+
defm : FCMLA_LANE_PATS<v4f16, V64,
996+
(v4f16 (bitconvert (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexD:$idx))))>;
997+
defm : FCMLA_LANE_PATS<v8f16, V128,
998+
(v8f16 (bitconvert (v4i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))>;
981999
}
9821000
let Predicates = [HasComplxNum, HasNEON] in {
9831001
defm : FCMLA_PATS<v2f32, V64>;
9841002
defm : FCMLA_PATS<v4f32, V128>;
9851003
defm : FCMLA_PATS<v2f64, V128>;
1004+
1005+
defm : FCMLA_LANE_PATS<v4f32, V128,
1006+
(v4f32 (bitconvert (v2i64 (AArch64duplane64 (v2i64 V128:$Rm), VectorIndexD:$idx))))>;
9861007
}
9871008

9881009
// v8.3a Pointer Authentication

‎llvm/test/CodeGen/AArch64/neon-vcmla.ll‎

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ entry:
99
ret <4 x half> %res
1010
}
1111

12+
define <4 x half> @test_16x4_lane_1(<4 x half> %a, <4 x half> %b, <4 x half> %c) {
13+
entry:
14+
; CHECK-LABEL: test_16x4_lane_1
15+
; CHECK: fcmla v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.h[1], #0
16+
;
17+
%c.cast = bitcast <4 x half> %c to <2 x i32>
18+
%c.dup = shufflevector <2 x i32> %c.cast , <2 x i32> undef, <2 x i32> <i32 1, i32 1>
19+
%c.res = bitcast <2 x i32> %c.dup to <4 x half>
20+
%res = tail call <4 x half> @llvm.aarch64.neon.vcmla.rot0.v4f16(<4 x half> %a, <4 x half> %b, <4 x half> %c.res)
21+
ret <4 x half> %res
22+
}
1223

1324
define <4 x half> @test_rot90_16x4(<4 x half> %a, <4 x half> %b, <4 x half> %c) {
1425
entry:
@@ -19,6 +30,18 @@ entry:
1930
ret <4 x half> %res
2031
}
2132

33+
define <4 x half> @test_rot90_16x4_lane_0(<4 x half> %a, <4 x half> %b, <4 x half> %c) {
34+
entry:
35+
; CHECK-LABEL: test_rot90_16x4_lane_0
36+
; CHECK: fcmla v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.h[0], #90
37+
;
38+
%c.cast = bitcast <4 x half> %c to <2 x i32>
39+
%c.dup = shufflevector <2 x i32> %c.cast , <2 x i32> undef, <2 x i32> <i32 0, i32 0>
40+
%c.res = bitcast <2 x i32> %c.dup to <4 x half>
41+
%res = tail call <4 x half> @llvm.aarch64.neon.vcmla.rot90.v4f16(<4 x half> %a, <4 x half> %b, <4 x half> %c.res)
42+
ret <4 x half> %res
43+
}
44+
2245
define <4 x half> @test_rot180_16x4(<4 x half> %a, <4 x half> %b, <4 x half> %c) {
2346
entry:
2447
; CHECK-LABEL: test_rot180_16x4
@@ -28,6 +51,18 @@ entry:
2851
ret <4 x half> %res
2952
}
3053

54+
define <4 x half> @test_rot180_16x4_lane_0(<4 x half> %a, <4 x half> %b, <8 x half> %c) {
55+
entry:
56+
; CHECK-LABEL: test_rot180_16x4_lane_0
57+
; CHECK: fcmla v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.h[0], #180
58+
59+
%c.cast = bitcast <8 x half> %c to <4 x i32>
60+
%c.dup = shufflevector <4 x i32> %c.cast , <4 x i32> undef, <2 x i32> <i32 0, i32 0>
61+
%c.res = bitcast <2 x i32> %c.dup to <4 x half>
62+
%res = tail call <4 x half> @llvm.aarch64.neon.vcmla.rot180.v4f16(<4 x half> %a, <4 x half> %b, <4 x half> %c.res)
63+
ret <4 x half> %res
64+
}
65+
3166
define <4 x half> @test_rot270_16x4(<4 x half> %a, <4 x half> %b, <4 x half> %c) {
3267
entry:
3368
; CHECK-LABEL: test_rot270_16x4
@@ -82,6 +117,18 @@ entry:
82117
ret <8 x half> %res
83118
}
84119

120+
define <8 x half> @test_16x8_lane_0(<8 x half> %a, <8 x half> %b, <8 x half> %c) {
121+
entry:
122+
; CHECK-LABEL: test_16x8_lane_0
123+
; CHECK: fcmla v{{[0-9]+}}.8h, v{{[0-9]+}}.8h, v{{[0-9]+}}.h[0], #0
124+
;
125+
%c.cast = bitcast <8 x half> %c to <4 x i32>
126+
%c.dup = shufflevector <4 x i32> %c.cast , <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
127+
%c.res = bitcast <4 x i32> %c.dup to <8 x half>
128+
%res = tail call <8 x half> @llvm.aarch64.neon.vcmla.rot0.v8f16(<8 x half> %a, <8 x half> %b, <8 x half> %c.res)
129+
ret <8 x half> %res
130+
}
131+
85132
define <8 x half> @test_rot90_16x8(<8 x half> %a, <8 x half> %b, <8 x half> %c) {
86133
entry:
87134
; CHECK-LABEL: test_rot90_16x8
@@ -91,6 +138,18 @@ entry:
91138
ret <8 x half> %res
92139
}
93140

141+
define <8 x half> @test_rot90_16x8_lane_1(<8 x half> %a, <8 x half> %b, <8 x half> %c) {
142+
entry:
143+
; CHECK-LABEL: test_rot90_16x8_lane_1
144+
; CHECK: fcmla v{{[0-9]+}}.8h, v{{[0-9]+}}.8h, v{{[0-9]+}}.h[1], #90
145+
;
146+
%c.cast = bitcast <8 x half> %c to <4 x i32>
147+
%c.dup = shufflevector <4 x i32> %c.cast , <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
148+
%c.res = bitcast <4 x i32> %c.dup to <8 x half>
149+
%res = tail call <8 x half> @llvm.aarch64.neon.vcmla.rot90.v8f16(<8 x half> %a, <8 x half> %b, <8 x half> %c.res)
150+
ret <8 x half> %res
151+
}
152+
94153
define <8 x half> @test_rot180_16x8(<8 x half> %a, <8 x half> %b, <8 x half> %c) {
95154
entry:
96155
; CHECK-LABEL: test_rot180_16x8
@@ -100,6 +159,18 @@ entry:
100159
ret <8 x half> %res
101160
}
102161

162+
define <8 x half> @test_rot180_16x8_lane_1(<8 x half> %a, <8 x half> %b, <8 x half> %c) {
163+
entry:
164+
; CHECK-LABEL: test_rot180_16x8_lane_1
165+
; CHECK: fcmla v{{[0-9]+}}.8h, v{{[0-9]+}}.8h, v{{[0-9]+}}.h[1], #180
166+
;
167+
%c.cast = bitcast <8 x half> %c to <4 x i32>
168+
%c.dup = shufflevector <4 x i32> %c.cast , <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
169+
%c.res = bitcast <4 x i32> %c.dup to <8 x half>
170+
%res = tail call <8 x half> @llvm.aarch64.neon.vcmla.rot180.v8f16(<8 x half> %a, <8 x half> %b, <8 x half> %c.res)
171+
ret <8 x half> %res
172+
}
173+
103174
define <8 x half> @test_rot270_16x8(<8 x half> %a, <8 x half> %b, <8 x half> %c) {
104175
entry:
105176
; CHECK-LABEL: test_rot270_16x8
@@ -109,6 +180,18 @@ entry:
109180
ret <8 x half> %res
110181
}
111182

183+
define <8 x half> @test_rot270_16x8_lane_0(<8 x half> %a, <8 x half> %b, <8 x half> %c) {
184+
entry:
185+
; CHECK-LABEL: test_rot270_16x8_lane_0
186+
; CHECK: fcmla v{{[0-9]+}}.8h, v{{[0-9]+}}.8h, v{{[0-9]+}}.h[0], #270
187+
;
188+
%c.cast = bitcast <8 x half> %c to <4 x i32>
189+
%c.dup = shufflevector <4 x i32> %c.cast , <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
190+
%c.res = bitcast <4 x i32> %c.dup to <8 x half>
191+
%res = tail call <8 x half> @llvm.aarch64.neon.vcmla.rot270.v8f16(<8 x half> %a, <8 x half> %b, <8 x half> %c.res)
192+
ret <8 x half> %res
193+
}
194+
112195
define <4 x float> @test_32x4(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
113196
entry:
114197
; CHECK-LABEL: test_32x4
@@ -118,6 +201,18 @@ entry:
118201
ret <4 x float> %res
119202
}
120203

204+
define <4 x float> @test_32x4_lane_0(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
205+
entry:
206+
; CHECK-LABEL: test_32x4_lane_0
207+
; CHECK: fcmla v{{[0-9]+}}.4s, v{{[0-9]+}}.4s, v{{[0-9]+}}.s[0], #0
208+
;
209+
%c.cast = bitcast <4 x float> %c to <2 x i64>
210+
%c.dup = shufflevector <2 x i64> %c.cast , <2 x i64> undef, <2 x i32> <i32 0, i32 0>
211+
%c.res = bitcast <2 x i64> %c.dup to <4 x float>
212+
%res = tail call <4 x float> @llvm.aarch64.neon.vcmla.rot0.v4f32(<4 x float> %a, <4 x float> %b, <4 x float> %c.res)
213+
ret <4 x float> %res
214+
}
215+
121216
define <4 x float> @test_rot90_32x4(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
122217
entry:
123218
; CHECK-LABEL: test_rot90_32x4

0 commit comments

Comments
 (0)