You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[LLVM][InstCombine] Enable constant folding for SVE add,and,eor,fadd,fdiv,fsub,orr & sub intrinsics. (#136849)
This is the subset of binops (mul and fmul are already enabled) whose
behaviour fully aligns with the equivalent SVE intrinsic. The omissions
are integer divides and shifts that are defined to return poison for
values where the intrinsics have a defined result. These will be covered
in a seperate PR.
Copy file name to clipboardExpand all lines: llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-simplify-binop.ll
+16-24Lines changed: 16 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -110,7 +110,7 @@ define <vscale x 4 x i32> @constant_mul_u_after_striping_inactive_lanes(<vscale
110
110
define <vscale x 4 x i32> @constant_add(<vscale x 4 x i1> %pg) #0 {
111
111
; CHECK-LABEL: define <vscale x 4 x i32> @constant_add(
112
112
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
113
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.add.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 7), <vscale x 4 x i32> splat (i32 3))
113
+
; CHECK-NEXT: [[R:%.*]] = select <vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 10), <vscale x 4 x i32> splat (i32 7)
114
114
; CHECK-NEXT: ret <vscale x 4 x i32> [[R]]
115
115
;
116
116
%r = call <vscale x 4 x i32> @llvm.aarch64.sve.add.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> splat (i327), <vscale x 4 x i32> splat (i323))
@@ -120,8 +120,7 @@ define <vscale x 4 x i32> @constant_add(<vscale x 4 x i1> %pg) #0 {
120
120
define <vscale x 4 x i32> @constant_add_u(<vscale x 4 x i1> %pg) #0 {
121
121
; CHECK-LABEL: define <vscale x 4 x i32> @constant_add_u(
122
122
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
123
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.add.u.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 7), <vscale x 4 x i32> splat (i32 3))
124
-
; CHECK-NEXT: ret <vscale x 4 x i32> [[R]]
123
+
; CHECK-NEXT: ret <vscale x 4 x i32> splat (i32 10)
125
124
;
126
125
%r = call <vscale x 4 x i32> @llvm.aarch64.sve.add.u.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> splat (i327), <vscale x 4 x i32> splat (i323))
127
126
ret <vscale x 4 x i32> %r
@@ -130,7 +129,7 @@ define <vscale x 4 x i32> @constant_add_u(<vscale x 4 x i1> %pg) #0 {
130
129
define <vscale x 4 x i32> @constant_and(<vscale x 4 x i1> %pg) #0 {
131
130
; CHECK-LABEL: define <vscale x 4 x i32> @constant_and(
132
131
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
133
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 7), <vscale x 4 x i32> splat (i32 14))
132
+
; CHECK-NEXT: [[R:%.*]] = select <vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 6), <vscale x 4 x i32> splat (i32 7)
134
133
; CHECK-NEXT: ret <vscale x 4 x i32> [[R]]
135
134
;
136
135
%r = call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> splat (i327), <vscale x 4 x i32> splat (i3214))
@@ -140,8 +139,7 @@ define <vscale x 4 x i32> @constant_and(<vscale x 4 x i1> %pg) #0 {
140
139
define <vscale x 4 x i32> @constant_and_u(<vscale x 4 x i1> %pg) #0 {
141
140
; CHECK-LABEL: define <vscale x 4 x i32> @constant_and_u(
142
141
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
143
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.and.u.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 7), <vscale x 4 x i32> splat (i32 14))
144
-
; CHECK-NEXT: ret <vscale x 4 x i32> [[R]]
142
+
; CHECK-NEXT: ret <vscale x 4 x i32> splat (i32 6)
145
143
;
146
144
%r = call <vscale x 4 x i32> @llvm.aarch64.sve.and.u.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> splat (i327), <vscale x 4 x i32> splat (i3214))
147
145
ret <vscale x 4 x i32> %r
@@ -150,7 +148,7 @@ define <vscale x 4 x i32> @constant_and_u(<vscale x 4 x i1> %pg) #0 {
150
148
define <vscale x 4 x i32> @constant_eor(<vscale x 4 x i1> %pg) #0 {
151
149
; CHECK-LABEL: define <vscale x 4 x i32> @constant_eor(
152
150
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
153
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 7), <vscale x 4 x i32> splat (i32 3))
151
+
; CHECK-NEXT: [[R:%.*]] = select <vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 4), <vscale x 4 x i32> splat (i32 7)
154
152
; CHECK-NEXT: ret <vscale x 4 x i32> [[R]]
155
153
;
156
154
%r = call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> splat (i327), <vscale x 4 x i32> splat (i323))
@@ -160,8 +158,7 @@ define <vscale x 4 x i32> @constant_eor(<vscale x 4 x i1> %pg) #0 {
160
158
define <vscale x 4 x i32> @constant_eor_u(<vscale x 4 x i1> %pg) #0 {
161
159
; CHECK-LABEL: define <vscale x 4 x i32> @constant_eor_u(
162
160
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
163
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.eor.u.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 7), <vscale x 4 x i32> splat (i32 3))
164
-
; CHECK-NEXT: ret <vscale x 4 x i32> [[R]]
161
+
; CHECK-NEXT: ret <vscale x 4 x i32> splat (i32 4)
165
162
;
166
163
%r = call <vscale x 4 x i32> @llvm.aarch64.sve.eor.u.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> splat (i327), <vscale x 4 x i32> splat (i323))
167
164
ret <vscale x 4 x i32> %r
@@ -170,7 +167,7 @@ define <vscale x 4 x i32> @constant_eor_u(<vscale x 4 x i1> %pg) #0 {
170
167
define <vscale x 4 x float> @constant_fadd(<vscale x 4 x i1> %pg) #0 {
171
168
; CHECK-LABEL: define <vscale x 4 x float> @constant_fadd(
172
169
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
173
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.fadd.nxv4f32(<vscale x 4 x i1> [[PG]], <vscale x 4 x float> splat (float 7.000000e+00), <vscale x 4 x float> splat (float 6.000000e+00))
170
+
; CHECK-NEXT: [[R:%.*]] = select <vscale x 4 x i1> [[PG]], <vscale x 4 x float> splat (float 1.300000e+01), <vscale x 4 x float> splat (float 7.000000e+00)
174
171
; CHECK-NEXT: ret <vscale x 4 x float> [[R]]
175
172
;
176
173
%r = call <vscale x 4 x float> @llvm.aarch64.sve.fadd.nxv4f32(<vscale x 4 x i1> %pg, <vscale x 4 x float> splat (float7.0), <vscale x 4 x float> splat (float6.0))
@@ -180,8 +177,7 @@ define <vscale x 4 x float> @constant_fadd(<vscale x 4 x i1> %pg) #0 {
180
177
define <vscale x 4 x float> @constant_fadd_u(<vscale x 4 x i1> %pg) #0 {
181
178
; CHECK-LABEL: define <vscale x 4 x float> @constant_fadd_u(
182
179
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
183
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.fadd.u.nxv4f32(<vscale x 4 x i1> [[PG]], <vscale x 4 x float> splat (float 7.000000e+00), <vscale x 4 x float> splat (float 6.000000e+00))
184
-
; CHECK-NEXT: ret <vscale x 4 x float> [[R]]
180
+
; CHECK-NEXT: ret <vscale x 4 x float> splat (float 1.300000e+01)
185
181
;
186
182
%r = call <vscale x 4 x float> @llvm.aarch64.sve.fadd.u.nxv4f32(<vscale x 4 x i1> %pg, <vscale x 4 x float> splat (float7.0), <vscale x 4 x float> splat (float6.0))
187
183
ret <vscale x 4 x float> %r
@@ -190,7 +186,7 @@ define <vscale x 4 x float> @constant_fadd_u(<vscale x 4 x i1> %pg) #0 {
190
186
define <vscale x 4 x float> @constant_fdiv(<vscale x 4 x i1> %pg) #0 {
191
187
; CHECK-LABEL: define <vscale x 4 x float> @constant_fdiv(
192
188
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
193
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.fdiv.nxv4f32(<vscale x 4 x i1> [[PG]], <vscale x 4 x float> splat (float 1.200000e+01), <vscale x 4 x float> splat (float 6.000000e+00))
189
+
; CHECK-NEXT: [[R:%.*]] = select <vscale x 4 x i1> [[PG]], <vscale x 4 x float> splat (float 2.000000e+00), <vscale x 4 x float> splat (float 1.200000e+01)
194
190
; CHECK-NEXT: ret <vscale x 4 x float> [[R]]
195
191
;
196
192
%r = call <vscale x 4 x float> @llvm.aarch64.sve.fdiv.nxv4f32(<vscale x 4 x i1> %pg, <vscale x 4 x float> splat (float12.0), <vscale x 4 x float> splat (float6.0))
@@ -200,8 +196,7 @@ define <vscale x 4 x float> @constant_fdiv(<vscale x 4 x i1> %pg) #0 {
200
196
define <vscale x 4 x float> @constant_fdiv_u(<vscale x 4 x i1> %pg) #0 {
201
197
; CHECK-LABEL: define <vscale x 4 x float> @constant_fdiv_u(
202
198
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
203
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.fdiv.u.nxv4f32(<vscale x 4 x i1> [[PG]], <vscale x 4 x float> splat (float 7.000000e+00), <vscale x 4 x float> splat (float 6.000000e+00))
204
-
; CHECK-NEXT: ret <vscale x 4 x float> [[R]]
199
+
; CHECK-NEXT: ret <vscale x 4 x float> splat (float 0x3FF2AAAAA0000000)
205
200
;
206
201
%r = call <vscale x 4 x float> @llvm.aarch64.sve.fdiv.u.nxv4f32(<vscale x 4 x i1> %pg, <vscale x 4 x float> splat (float7.0), <vscale x 4 x float> splat (float6.0))
207
202
ret <vscale x 4 x float> %r
@@ -229,7 +224,7 @@ define <vscale x 4 x float> @constant_fmul_u(<vscale x 4 x i1> %pg) #0 {
229
224
define <vscale x 4 x float> @constant_fsub(<vscale x 4 x i1> %pg) #0 {
230
225
; CHECK-LABEL: define <vscale x 4 x float> @constant_fsub(
231
226
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
232
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.fsub.nxv4f32(<vscale x 4 x i1> [[PG]], <vscale x 4 x float> splat (float 7.000000e+00), <vscale x 4 x float> splat (float 6.000000e+00))
227
+
; CHECK-NEXT: [[R:%.*]] = select <vscale x 4 x i1> [[PG]], <vscale x 4 x float> splat (float 1.000000e+00), <vscale x 4 x float> splat (float 7.000000e+00)
233
228
; CHECK-NEXT: ret <vscale x 4 x float> [[R]]
234
229
;
235
230
%r = call <vscale x 4 x float> @llvm.aarch64.sve.fsub.nxv4f32(<vscale x 4 x i1> %pg, <vscale x 4 x float> splat (float7.0), <vscale x 4 x float> splat (float6.0))
@@ -239,8 +234,7 @@ define <vscale x 4 x float> @constant_fsub(<vscale x 4 x i1> %pg) #0 {
239
234
define <vscale x 4 x float> @constant_fsub_u(<vscale x 4 x i1> %pg) #0 {
240
235
; CHECK-LABEL: define <vscale x 4 x float> @constant_fsub_u(
241
236
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
242
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.fsub.u.nxv4f32(<vscale x 4 x i1> [[PG]], <vscale x 4 x float> splat (float 7.000000e+00), <vscale x 4 x float> splat (float 6.000000e+00))
243
-
; CHECK-NEXT: ret <vscale x 4 x float> [[R]]
237
+
; CHECK-NEXT: ret <vscale x 4 x float> splat (float 1.000000e+00)
244
238
;
245
239
%r = call <vscale x 4 x float> @llvm.aarch64.sve.fsub.u.nxv4f32(<vscale x 4 x i1> %pg, <vscale x 4 x float> splat (float7.0), <vscale x 4 x float> splat (float6.0))
246
240
ret <vscale x 4 x float> %r
@@ -268,7 +262,7 @@ define <vscale x 4 x i32> @constant_mul_u(<vscale x 4 x i1> %pg) #0 {
268
262
define <vscale x 4 x i32> @constant_orr(<vscale x 4 x i1> %pg) #0 {
269
263
; CHECK-LABEL: define <vscale x 4 x i32> @constant_orr(
270
264
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
271
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.orr.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 13), <vscale x 4 x i32> splat (i32 3))
265
+
; CHECK-NEXT: [[R:%.*]] = select <vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 15), <vscale x 4 x i32> splat (i32 13)
272
266
; CHECK-NEXT: ret <vscale x 4 x i32> [[R]]
273
267
;
274
268
%r = call <vscale x 4 x i32> @llvm.aarch64.sve.orr.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> splat (i3213), <vscale x 4 x i32> splat (i323))
@@ -278,8 +272,7 @@ define <vscale x 4 x i32> @constant_orr(<vscale x 4 x i1> %pg) #0 {
278
272
define <vscale x 4 x i32> @constant_orr_u(<vscale x 4 x i1> %pg) #0 {
279
273
; CHECK-LABEL: define <vscale x 4 x i32> @constant_orr_u(
280
274
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
281
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.orr.u.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 13), <vscale x 4 x i32> splat (i32 3))
282
-
; CHECK-NEXT: ret <vscale x 4 x i32> [[R]]
275
+
; CHECK-NEXT: ret <vscale x 4 x i32> splat (i32 15)
283
276
;
284
277
%r = call <vscale x 4 x i32> @llvm.aarch64.sve.orr.u.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> splat (i3213), <vscale x 4 x i32> splat (i323))
285
278
ret <vscale x 4 x i32> %r
@@ -351,7 +344,7 @@ define <vscale x 4 x i32> @constant_sdiv_u_with_overflow(<vscale x 4 x i1> %pg)
351
344
define <vscale x 4 x i32> @constant_sub(<vscale x 4 x i1> %pg) #0 {
352
345
; CHECK-LABEL: define <vscale x 4 x i32> @constant_sub(
353
346
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
354
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.sub.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 7), <vscale x 4 x i32> splat (i32 3))
347
+
; CHECK-NEXT: [[R:%.*]] = select <vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 4), <vscale x 4 x i32> splat (i32 7)
355
348
; CHECK-NEXT: ret <vscale x 4 x i32> [[R]]
356
349
;
357
350
%r = call <vscale x 4 x i32> @llvm.aarch64.sve.sub.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> splat (i327), <vscale x 4 x i32> splat (i323))
@@ -361,8 +354,7 @@ define <vscale x 4 x i32> @constant_sub(<vscale x 4 x i1> %pg) #0 {
361
354
define <vscale x 4 x i32> @constant_sub_u(<vscale x 4 x i1> %pg) #0 {
362
355
; CHECK-LABEL: define <vscale x 4 x i32> @constant_sub_u(
363
356
; CHECK-SAME: <vscale x 4 x i1> [[PG:%.*]]) #[[ATTR0]] {
364
-
; CHECK-NEXT: [[R:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.sub.u.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> splat (i32 7), <vscale x 4 x i32> splat (i32 3))
365
-
; CHECK-NEXT: ret <vscale x 4 x i32> [[R]]
357
+
; CHECK-NEXT: ret <vscale x 4 x i32> splat (i32 4)
366
358
;
367
359
%r = call <vscale x 4 x i32> @llvm.aarch64.sve.sub.u.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> splat (i327), <vscale x 4 x i32> splat (i323))
0 commit comments