Skip to content

Commit 4c4c01e

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 b890c17 commit 4c4c01e

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
@@ -1214,3 +1214,48 @@ define <vscale x 2 x double> @vpmerge_vfwsub.w_tied(<vscale x 2 x double> %passt
12141214
%b = call <vscale x 2 x double> @llvm.vp.merge.nxv2f64(<vscale x 2 x i1> %mask, <vscale x 2 x double> %a, <vscale x 2 x double> %passthru, i32 %vl)
12151215
ret <vscale x 2 x double> %b
12161216
}
1217+
1218+
; FIXME: We don't currently handle vmerge with an implicit passthru if the true
1219+
; operand also has a tied dest. This could be folded into a masked vmacc with ta
1220+
; policy.
1221+
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) {
1222+
; CHECK-LABEL: true_tied_dest_vmerge_implicit_passthru:
1223+
; CHECK: # %bb.0:
1224+
; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, ma
1225+
; CHECK-NEXT: vmv1r.v v11, v8
1226+
; CHECK-NEXT: vmacc.vv v11, v9, v10
1227+
; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
1228+
; CHECK-NEXT: vmerge.vvm v8, v8, v11, v0
1229+
; CHECK-NEXT: ret
1230+
%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)
1231+
%b = call <vscale x 2 x i32> @llvm.riscv.vmerge.nxv2i32.nxv2i32(
1232+
<vscale x 2 x i32> poison,
1233+
<vscale x 2 x i32> %passthru,
1234+
<vscale x 2 x i32> %a,
1235+
<vscale x 2 x i1> %m,
1236+
i64 %avl
1237+
)
1238+
ret <vscale x 2 x i32> %b
1239+
}
1240+
1241+
; FIXME: We don't currently handle vmerge with an implicit passthru if the true
1242+
; operand also has a tied dest, e.g. has a passthru since it's a masked
1243+
; pseudo. This could be folded into a masked vadd with ta policy.
1244+
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) {
1245+
; CHECK-LABEL: true_mask_vmerge_implicit_passthru:
1246+
; CHECK: # %bb.0:
1247+
; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu
1248+
; CHECK-NEXT: vmv1r.v v11, v8
1249+
; CHECK-NEXT: vadd.vv v11, v9, v10, v0.t
1250+
; CHECK-NEXT: vmv.v.v v8, v11
1251+
; CHECK-NEXT: ret
1252+
%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)
1253+
%b = call <vscale x 2 x i32> @llvm.riscv.vmerge.nxv2i32.nxv2i32(
1254+
<vscale x 2 x i32> poison,
1255+
<vscale x 2 x i32> %passthru,
1256+
<vscale x 2 x i32> %a,
1257+
<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),
1258+
i64 %avl
1259+
)
1260+
ret <vscale x 2 x i32> %b
1261+
}

0 commit comments

Comments
 (0)