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
Copy file name to clipboardExpand all lines: llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-masked-vops.ll
+29Lines changed: 29 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,20 @@ define <vscale x 2 x i32> @vpmerge_vadd(<vscale x 2 x i32> %passthru, <vscale x
18
18
}
19
19
declare <vscale x 2 x i32> @llvm.riscv.vadd.mask.nxv2i32.nxv2i32(<vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i1>, i64, i64)
20
20
21
+
; We should be able to merge vmerge into its op if the masks are the same
22
+
define <vscale x 2 x i32> @vmerge_vadd_same_mask(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %x, <vscale x 2 x i32> %y, <vscale x 2 x i1> %m, i64%vl) {
23
+
; CHECK-LABEL: vmerge_vadd_same_mask:
24
+
; CHECK: # %bb.0:
25
+
; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
26
+
; CHECK-NEXT: vadd.vv v9, v9, v10, v0.t
27
+
; CHECK-NEXT: vsetvli zero, zero, e32, m1, tu, ma
28
+
; CHECK-NEXT: vmerge.vvm v8, v8, v9, v0
29
+
; CHECK-NEXT: ret
30
+
%a = call <vscale x 2 x i32> @llvm.riscv.vadd.mask.nxv2i32.nxv2i32(<vscale x 2 x i32> poison, <vscale x 2 x i32> %x, <vscale x 2 x i32> %y, <vscale x 2 x i1> %m, i64%vl, i640)
31
+
%b = call <vscale x 2 x i32> @llvm.riscv.vmerge.nxv2i32.nxv2i32(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %passthru, <vscale x 2 x i32> %a, <vscale x 2 x i1> %m, i64%vl)
32
+
ret <vscale x 2 x i32> %b
33
+
}
34
+
21
35
define <vscale x 2 x i32> @vpmerge_vsub(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %x, <vscale x 2 x i32> %y, <vscale x 2 x i1> %m, i64%vl) {
22
36
; CHECK-LABEL: vpmerge_vsub:
23
37
; CHECK: # %bb.0:
@@ -258,3 +272,18 @@ entry:
258
272
%res = call <vscale x 2 x i32> @llvm.vp.merge.nxv2i32(<vscale x 2 x i1> %m, <vscale x 2 x i32> %i, <vscale x 2 x i32> %passthru, i32%evl)
259
273
ret <vscale x 2 x i32> %res
260
274
}
275
+
276
+
; Test that a vp op and a vp merge with the same mask and evl are merged
277
+
declare <vscale x 2 x i32> @llvm.vp.add.nxv2i32(<vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i1>, i32)
278
+
define <vscale x 2 x i32> @vmerge_vadd(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %x, <vscale x 2 x i32> %y, <vscale x 2 x i1> %m, i32zeroext%evl) {
279
+
; CHECK-LABEL: vmerge_vadd:
280
+
; CHECK: # %bb.0:
281
+
; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
282
+
; CHECK-NEXT: vadd.vv v9, v9, v10, v0.t
283
+
; CHECK-NEXT: vsetvli zero, zero, e32, m1, tu, ma
284
+
; CHECK-NEXT: vmerge.vvm v8, v8, v9, v0
285
+
; CHECK-NEXT: ret
286
+
%1 = call <vscale x 2 x i32> @llvm.vp.add.nxv2i32(<vscale x 2 x i32> %x, <vscale x 2 x i32> %y, <vscale x 2 x i1> %m, i32%evl)
287
+
%2 = call <vscale x 2 x i32> @llvm.vp.merge.nxv2i32(<vscale x 2 x i1> %m, <vscale x 2 x i32> %1, <vscale x 2 x i32> %passthru, i32%evl)
0 commit comments