Skip to content

Commit 1fae3b7

Browse files
committed
Add tests for cases where we could fold a vmerge into its ops, but don't due to
it having an implicit merge operand.
1 parent f15b7de commit 1fae3b7

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,3 +1203,48 @@ define <vscale x 2 x i64> @vpmerge_vwsub.w_tied(<vscale x 2 x i64> %passthru, <v
12031203
%b = call <vscale x 2 x i64> @llvm.vp.merge.nxv2i64(<vscale x 2 x i1> %mask, <vscale x 2 x i64> %a, <vscale x 2 x i64> %passthru, i32 %vl)
12041204
ret <vscale x 2 x i64> %b
12051205
}
1206+
1207+
; FIXME: We don't currently handle vmerge with an implicit passthru if the true
1208+
; operand also has a tied dest. This could be folded into a masked vmacc with ta
1209+
; policy.
1210+
define <vscale x 2 x i32> @true_tied_dest_vmerge_implicit_passthru(<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 %avl) {
1211+
; CHECK-LABEL: true_tied_dest_vmerge_implicit_passthru:
1212+
; CHECK: # %bb.0:
1213+
; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, ma
1214+
; CHECK-NEXT: vmv1r.v v11, v8
1215+
; CHECK-NEXT: vmacc.vv v11, v9, v10
1216+
; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
1217+
; CHECK-NEXT: vmerge.vvm v8, v8, v11, v0
1218+
; CHECK-NEXT: ret
1219+
%a = call <vscale x 2 x i32> @llvm.riscv.vmacc.nxv2i32.nxv2i32(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %x, <vscale x 2 x i32> %y, i64 %avl, i64 0)
1220+
%b = call <vscale x 2 x i32> @llvm.riscv.vmerge.nxv2i32.nxv2i32(
1221+
<vscale x 2 x i32> poison,
1222+
<vscale x 2 x i32> %passthru,
1223+
<vscale x 2 x i32> %a,
1224+
<vscale x 2 x i1> %m,
1225+
i64 %avl
1226+
)
1227+
ret <vscale x 2 x i32> %b
1228+
}
1229+
1230+
; FIXME: We don't currently handle vmerge with an implicit passthru if the true
1231+
; operand also has a tied dest, e.g. has a passthru since it's a masked
1232+
; pseudo. This could be folded into a masked vadd with ta policy.
1233+
define <vscale x 2 x i32> @true_mask_vmerge_implicit_passthru(<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 %avl) {
1234+
; CHECK-LABEL: true_mask_vmerge_implicit_passthru:
1235+
; CHECK: # %bb.0:
1236+
; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu
1237+
; CHECK-NEXT: vmv1r.v v11, v8
1238+
; CHECK-NEXT: vadd.vv v11, v9, v10, v0.t
1239+
; CHECK-NEXT: vmv.v.v v8, v11
1240+
; CHECK-NEXT: ret
1241+
%a = call <vscale x 2 x i32> @llvm.riscv.vadd.mask.nxv2i32.nxv2i32(<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 %avl, i64 0)
1242+
%b = call <vscale x 2 x i32> @llvm.riscv.vmerge.nxv2i32.nxv2i32(
1243+
<vscale x 2 x i32> poison,
1244+
<vscale x 2 x i32> %passthru,
1245+
<vscale x 2 x i32> %a,
1246+
<vscale x 2 x i1> shufflevector(<vscale x 2 x i1> insertelement(<vscale x 2 x i1> poison, i1 true, i32 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer),
1247+
i64 %avl
1248+
)
1249+
ret <vscale x 2 x i32> %b
1250+
}

0 commit comments

Comments
 (0)