Skip to content

Commit b5e0848

Browse files
committed
[RISCV] Add tests for vmerge and op where masks are the same. NFC
1 parent 8f320df commit b5e0848

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-masked-vops.ll

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ define <vscale x 2 x i32> @vpmerge_vadd(<vscale x 2 x i32> %passthru, <vscale x
1818
}
1919
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)
2020

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, i64 0)
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+
2135
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) {
2236
; CHECK-LABEL: vpmerge_vsub:
2337
; CHECK: # %bb.0:
@@ -258,3 +272,18 @@ entry:
258272
%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)
259273
ret <vscale x 2 x i32> %res
260274
}
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, i32 zeroext %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)
288+
ret <vscale x 2 x i32> %2
289+
}

0 commit comments

Comments
 (0)