237 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=riscv64 -mattr=+v | FileCheck %s3 4define <vscale x 2 x i32> @vpmerge_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, i64 %vl) {5; CHECK-LABEL: vpmerge_vadd:6; CHECK: # %bb.0:7; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu8; CHECK-NEXT: vadd.vv v8, v9, v10, v0.t9; CHECK-NEXT: ret10 %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 %vl, i64 1)11 %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> splat (i1 -1), i64 %vl)12 ret <vscale x 2 x i32> %b13}14 15define <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) {16; CHECK-LABEL: vpmerge_vsub:17; CHECK: # %bb.0:18; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu19; CHECK-NEXT: vsub.vv v8, v9, v10, v0.t20; CHECK-NEXT: ret21 %a = call <vscale x 2 x i32> @llvm.riscv.vsub.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 %vl, i64 1)22 %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> splat (i1 -1), i64 %vl)23 ret <vscale x 2 x i32> %b24}25 26define <vscale x 2 x float> @vpmerge_vfadd(<vscale x 2 x float> %passthru, <vscale x 2 x float> %x, <vscale x 2 x float> %y, <vscale x 2 x i1> %m, i64 %vl) {27; CHECK-LABEL: vpmerge_vfadd:28; CHECK: # %bb.0:29; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu30; CHECK-NEXT: vfadd.vv v8, v9, v10, v0.t31; CHECK-NEXT: ret32 %a = call <vscale x 2 x float> @llvm.riscv.vfadd.mask.nxv2f32.nxv2f32(<vscale x 2 x float> %passthru, <vscale x 2 x float> %x, <vscale x 2 x float> %y, <vscale x 2 x i1> %m, i64 7, i64 %vl, i64 1)33 %b = call <vscale x 2 x float> @llvm.riscv.vmerge.nxv2f32.nxv2f32(<vscale x 2 x float> %passthru, <vscale x 2 x float> %passthru, <vscale x 2 x float> %a, <vscale x 2 x i1> splat (i1 -1), i64 %vl)34 35 ret <vscale x 2 x float> %b36}37 38define <vscale x 2 x float> @vpmerge_vfsub(<vscale x 2 x float> %passthru, <vscale x 2 x float> %x, <vscale x 2 x float> %y, <vscale x 2 x i1> %m, i64 %vl) {39; CHECK-LABEL: vpmerge_vfsub:40; CHECK: # %bb.0:41; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu42; CHECK-NEXT: vfsub.vv v8, v9, v10, v0.t43; CHECK-NEXT: ret44 %a = call <vscale x 2 x float> @llvm.riscv.vfsub.mask.nxv2f32.nxv2f32(<vscale x 2 x float> %passthru, <vscale x 2 x float> %x, <vscale x 2 x float> %y, <vscale x 2 x i1> %m, i64 7, i64 %vl, i64 1)45 %b = call <vscale x 2 x float> @llvm.riscv.vmerge.nxv2f32.nxv2f32(<vscale x 2 x float> %passthru, <vscale x 2 x float> %passthru, <vscale x 2 x float> %a, <vscale x 2 x i1> splat (i1 -1), i64 %vl)46 ret <vscale x 2 x float> %b47}48 49define <vscale x 2 x i32> @vpmerge_vwadd(<vscale x 2 x i32> %passthru, <vscale x 2 x i16> %x, <vscale x 2 x i16> %y, <vscale x 2 x i1> %m, i64 %vl) {50; CHECK-LABEL: vpmerge_vwadd:51; CHECK: # %bb.0:52; CHECK-NEXT: vsetvli zero, a0, e16, mf2, tu, mu53; CHECK-NEXT: vwadd.vv v8, v9, v10, v0.t54; CHECK-NEXT: ret55 %a = call <vscale x 2 x i32> @llvm.riscv.vwadd.mask.nxv2i32.nxv2i16.nxv2i16(<vscale x 2 x i32> %passthru, <vscale x 2 x i16> %x, <vscale x 2 x i16> %y, <vscale x 2 x i1> %m, i64 %vl, i64 1)56 %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> splat (i1 -1), i64 %vl)57 ret <vscale x 2 x i32> %b58}59 60define <vscale x 2 x i32> @vpmerge_vle(<vscale x 2 x i32> %passthru, ptr %p, <vscale x 2 x i1> %m, i64 %vl) {61; CHECK-LABEL: vpmerge_vle:62; CHECK: # %bb.0:63; CHECK-NEXT: vsetvli zero, a1, e32, m1, tu, mu64; CHECK-NEXT: vle32.v v8, (a0), v0.t65; CHECK-NEXT: ret66 %a = call <vscale x 2 x i32> @llvm.riscv.vle.mask.nxv2i32(67 <vscale x 2 x i32> %passthru,68 ptr %p,69 <vscale x 2 x i1> %m,70 i64 %vl, i64 1)71 %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> splat (i1 -1), i64 %vl)72 ret <vscale x 2 x i32> %b73}74 75define <vscale x 2 x i32> @vpmerge_vslideup(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %v, i64 %x, <vscale x 2 x i1> %m, i64 %vl) {76; CHECK-LABEL: vpmerge_vslideup:77; CHECK: # %bb.0:78; CHECK-NEXT: vsetvli zero, a1, e32, m1, tu, mu79; CHECK-NEXT: vslideup.vx v8, v9, a0, v0.t80; CHECK-NEXT: ret81 %a = call <vscale x 2 x i32> @llvm.riscv.vslideup.mask.nxv2i32(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %v, i64 %x, <vscale x 2 x i1> %m, i64 %vl, i64 0)82 %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> splat (i1 -1), i64 %vl)83 ret <vscale x 2 x i32> %b84}85 86define <vscale x 2 x i32> @vpmerge_vslidedown(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %v, i64 %x, <vscale x 2 x i1> %m, i64 %vl) {87; CHECK-LABEL: vpmerge_vslidedown:88; CHECK: # %bb.0:89; CHECK-NEXT: vsetvli zero, a1, e32, m1, tu, mu90; CHECK-NEXT: vslidedown.vx v8, v9, a0, v0.t91; CHECK-NEXT: ret92 %a = call <vscale x 2 x i32> @llvm.riscv.vslidedown.mask.nxv2i32(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %v, i64 %x, <vscale x 2 x i1> %m, i64 %vl, i64 0)93 %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> splat (i1 -1), i64 %vl)94 ret <vscale x 2 x i32> %b95}96 97define <vscale x 2 x i32> @vpmerge_vslide1up(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %v, i32 %x, <vscale x 2 x i1> %m, i64 %vl) {98; CHECK-LABEL: vpmerge_vslide1up:99; CHECK: # %bb.0:100; CHECK-NEXT: vsetvli zero, a1, e32, m1, tu, mu101; CHECK-NEXT: vslide1up.vx v8, v9, a0, v0.t102; CHECK-NEXT: ret103 %a = call <vscale x 2 x i32> @llvm.riscv.vslide1up.mask.nxv2i32(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %v, i32 %x, <vscale x 2 x i1> %m, i64 %vl, i64 0)104 %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> splat (i1 -1), i64 %vl)105 ret <vscale x 2 x i32> %b106}107 108define <vscale x 2 x i32> @vpmerge_vslide1down(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %v, i32 %x, <vscale x 2 x i1> %m, i64 %vl) {109; CHECK-LABEL: vpmerge_vslide1down:110; CHECK: # %bb.0:111; CHECK-NEXT: vsetvli zero, a1, e32, m1, tu, mu112; CHECK-NEXT: vslide1down.vx v8, v9, a0, v0.t113; CHECK-NEXT: ret114 %a = call <vscale x 2 x i32> @llvm.riscv.vslide1down.mask.nxv2i32(<vscale x 2 x i32> %passthru, <vscale x 2 x i32> %v, i32 %x, <vscale x 2 x i1> %m, i64 %vl, i64 0)115 %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> splat (i1 -1), i64 %vl)116 ret <vscale x 2 x i32> %b117}118 119; Tests for folding vmerge into its ops when their VLs differ120 121; Can fold with VL=2122define <vscale x 2 x i32> @vmerge_smaller_vl_same_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) {123; CHECK-LABEL: vmerge_smaller_vl_same_passthru:124; CHECK: # %bb.0:125; CHECK-NEXT: vsetivli zero, 2, e32, m1, tu, mu126; CHECK-NEXT: vadd.vv v8, v9, v10, v0.t127; CHECK-NEXT: ret128 %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 3, i64 0)129 %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> splat (i1 -1), i64 2)130 ret <vscale x 2 x i32> %b131}132 133; Can fold with VL=2134define <vscale x 2 x i32> @vmerge_larger_vl_same_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) {135; CHECK-LABEL: vmerge_larger_vl_same_passthru:136; CHECK: # %bb.0:137; CHECK-NEXT: vsetivli zero, 2, e32, m1, tu, mu138; CHECK-NEXT: vadd.vv v8, v9, v10, v0.t139; CHECK-NEXT: ret140 %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 2, i64 0)141 %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> splat (i1 -1), i64 3)142 ret <vscale x 2 x i32> %b143}144 145; Can fold with VL=2146define <vscale x 2 x i32> @vmerge_smaller_vl_different_passthru(<vscale x 2 x i32> %pt1, <vscale x 2 x i32> %pt2, <vscale x 2 x i32> %x, <vscale x 2 x i32> %y, <vscale x 2 x i1> %m) {147; CHECK-LABEL: vmerge_smaller_vl_different_passthru:148; CHECK: # %bb.0:149; CHECK-NEXT: vsetivli zero, 2, e32, m1, tu, mu150; CHECK-NEXT: vadd.vv v8, v10, v11, v0.t151; CHECK-NEXT: vmv.v.v v9, v8152; CHECK-NEXT: vmv1r.v v8, v9153; CHECK-NEXT: ret154 %a = call <vscale x 2 x i32> @llvm.riscv.vadd.mask.nxv2i32.nxv2i32(<vscale x 2 x i32> %pt1, <vscale x 2 x i32> %x, <vscale x 2 x i32> %y, <vscale x 2 x i1> %m, i64 3, i64 0)155 %b = call <vscale x 2 x i32> @llvm.riscv.vmerge.nxv2i32.nxv2i32(<vscale x 2 x i32> %pt2, <vscale x 2 x i32> %pt2, <vscale x 2 x i32> %a, <vscale x 2 x i1> splat (i1 -1), i64 2)156 ret <vscale x 2 x i32> %b157}158 159; Can't fold this because we need to take elements from both %pt1 and %pt2160define <vscale x 2 x i32> @vmerge_larger_vl_different_passthru(<vscale x 2 x i32> %pt1, <vscale x 2 x i32> %pt2, <vscale x 2 x i32> %x, <vscale x 2 x i32> %y, <vscale x 2 x i1> %m) {161; CHECK-LABEL: vmerge_larger_vl_different_passthru:162; CHECK: # %bb.0:163; CHECK-NEXT: vsetivli zero, 2, e32, m1, tu, mu164; CHECK-NEXT: vadd.vv v8, v10, v11, v0.t165; CHECK-NEXT: vsetivli zero, 3, e32, m1, tu, ma166; CHECK-NEXT: vmv.v.v v9, v8167; CHECK-NEXT: vmv1r.v v8, v9168; CHECK-NEXT: ret169 %a = call <vscale x 2 x i32> @llvm.riscv.vadd.mask.nxv2i32.nxv2i32(<vscale x 2 x i32> %pt1, <vscale x 2 x i32> %x, <vscale x 2 x i32> %y, <vscale x 2 x i1> %m, i64 2, i64 0)170 %b = call <vscale x 2 x i32> @llvm.riscv.vmerge.nxv2i32.nxv2i32(<vscale x 2 x i32> %pt2, <vscale x 2 x i32> %pt2, <vscale x 2 x i32> %a, <vscale x 2 x i1> splat (i1 -1), i64 3)171 ret <vscale x 2 x i32> %b172}173 174; Can fold with VL=2175define <vscale x 2 x i32> @vmerge_smaller_vl_poison_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) {176; CHECK-LABEL: vmerge_smaller_vl_poison_passthru:177; CHECK: # %bb.0:178; CHECK-NEXT: vsetivli zero, 2, e32, m1, tu, mu179; CHECK-NEXT: vadd.vv v8, v9, v10, v0.t180; CHECK-NEXT: ret181 %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 3, i64 0)182 %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> splat (i1 -1), i64 2)183 ret <vscale x 2 x i32> %b184}185 186; Can fold with VL=2187define <vscale x 2 x i32> @vmerge_larger_vl_poison_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) {188; CHECK-LABEL: vmerge_larger_vl_poison_passthru:189; CHECK: # %bb.0:190; CHECK-NEXT: vsetivli zero, 2, e32, m1, tu, mu191; CHECK-NEXT: vadd.vv v8, v9, v10, v0.t192; CHECK-NEXT: ret193 %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 2, i64 0)194 %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> splat (i1 -1), i64 3)195 ret <vscale x 2 x i32> %b196}197 198; Test VFCVT_RM199define <vscale x 2 x i32> @vmerge_vfcvt_rm(<vscale x 2 x i32> %passthru, <vscale x 2 x float> %a, <vscale x 2 x i1> %m, i32 zeroext %evl) {200; CHECK-LABEL: vmerge_vfcvt_rm:201; CHECK: # %bb.0: # %entry202; CHECK-NEXT: fsrmi a1, 2203; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu204; CHECK-NEXT: vfcvt.x.f.v v8, v9, v0.t205; CHECK-NEXT: fsrm a1206; CHECK-NEXT: ret207entry:208 %floor = call <vscale x 2 x float> @llvm.floor.nxv2f32(<vscale x 2 x float> %a)209 %i = fptosi <vscale x 2 x float> %floor to <vscale x 2 x i32>210 %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)211 ret <vscale x 2 x i32> %res212}213 214; Test VIOTA_M215define <vscale x 2 x i32> @vpmerge_viota(<vscale x 2 x i32> %passthru, <vscale x 2 x i1> %m, <vscale x 2 x i1> %vm, i32 zeroext %vl) {216; CHECK-LABEL: vpmerge_viota:217; CHECK: # %bb.0:218; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu219; CHECK-NEXT: viota.m v8, v9, v0.t220; CHECK-NEXT: ret221 %1 = zext i32 %vl to i64222 %a = call <vscale x 2 x i32> @llvm.riscv.viota.mask.nxv2i32(<vscale x 2 x i32> poison, <vscale x 2 x i1> %vm, <vscale x 2 x i1> %m, i64 %1, i64 0)223 %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> splat (i1 -1), i64 %1)224 ret <vscale x 2 x i32> %b225}226 227define <vscale x 2 x i32> @vpmerge_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) {228; CHECK-LABEL: vpmerge_vadd_same_mask:229; CHECK: # %bb.0:230; CHECK-NEXT: vsetvli zero, a0, e32, m1, tu, mu231; CHECK-NEXT: vadd.vv v8, v9, v10, v0.t232; CHECK-NEXT: ret233 %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 %vl, i64 1)234 %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)235 ret <vscale x 2 x i32> %b236}237