1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -mtriple=riscv32 -mattr=+experimental-v -target-abi=ilp32 \ 3; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32 4; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -target-abi=lp64 \ 5; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64 6 7; This tests a mix of vmacc and vmadd by using different operand orders to 8; trigger commuting in TwoAddressInstructionPass. 9 10define <vscale x 1 x i8> @vmadd_vv_nxv1i8(<vscale x 1 x i8> %va, <vscale x 1 x i8> %vb, <vscale x 1 x i8> %vc) { 11; CHECK-LABEL: vmadd_vv_nxv1i8: 12; CHECK: # %bb.0: 13; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, mu 14; CHECK-NEXT: vmadd.vv v8, v9, v10 15; CHECK-NEXT: ret 16 %x = mul <vscale x 1 x i8> %va, %vb 17 %y = add <vscale x 1 x i8> %x, %vc 18 ret <vscale x 1 x i8> %y 19} 20 21define <vscale x 1 x i8> @vmadd_vx_nxv1i8(<vscale x 1 x i8> %va, <vscale x 1 x i8> %vb, i8 %c) { 22; CHECK-LABEL: vmadd_vx_nxv1i8: 23; CHECK: # %bb.0: 24; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, mu 25; CHECK-NEXT: vmadd.vx v8, a0, v9 26; CHECK-NEXT: ret 27 %head = insertelement <vscale x 1 x i8> undef, i8 %c, i32 0 28 %splat = shufflevector <vscale x 1 x i8> %head, <vscale x 1 x i8> undef, <vscale x 1 x i32> zeroinitializer 29 %x = mul <vscale x 1 x i8> %va, %splat 30 %y = add <vscale x 1 x i8> %x, %vb 31 ret <vscale x 1 x i8> %y 32} 33 34define <vscale x 2 x i8> @vmadd_vv_nxv2i8(<vscale x 2 x i8> %va, <vscale x 2 x i8> %vb, <vscale x 2 x i8> %vc) { 35; CHECK-LABEL: vmadd_vv_nxv2i8: 36; CHECK: # %bb.0: 37; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, mu 38; CHECK-NEXT: vmadd.vv v8, v10, v9 39; CHECK-NEXT: ret 40 %x = mul <vscale x 2 x i8> %va, %vc 41 %y = add <vscale x 2 x i8> %x, %vb 42 ret <vscale x 2 x i8> %y 43} 44 45define <vscale x 2 x i8> @vmadd_vx_nxv2i8(<vscale x 2 x i8> %va, <vscale x 2 x i8> %vb, i8 %c) { 46; CHECK-LABEL: vmadd_vx_nxv2i8: 47; CHECK: # %bb.0: 48; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, mu 49; CHECK-NEXT: vmacc.vx v8, a0, v9 50; CHECK-NEXT: ret 51 %head = insertelement <vscale x 2 x i8> undef, i8 %c, i32 0 52 %splat = shufflevector <vscale x 2 x i8> %head, <vscale x 2 x i8> undef, <vscale x 2 x i32> zeroinitializer 53 %x = mul <vscale x 2 x i8> %vb, %splat 54 %y = add <vscale x 2 x i8> %x, %va 55 ret <vscale x 2 x i8> %y 56} 57 58define <vscale x 4 x i8> @vmadd_vv_nxv4i8(<vscale x 4 x i8> %va, <vscale x 4 x i8> %vb, <vscale x 4 x i8> %vc) { 59; CHECK-LABEL: vmadd_vv_nxv4i8: 60; CHECK: # %bb.0: 61; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, mu 62; CHECK-NEXT: vmadd.vv v8, v9, v10 63; CHECK-NEXT: ret 64 %x = mul <vscale x 4 x i8> %vb, %va 65 %y = add <vscale x 4 x i8> %x, %vc 66 ret <vscale x 4 x i8> %y 67} 68 69define <vscale x 4 x i8> @vmadd_vx_nxv4i8(<vscale x 4 x i8> %va, <vscale x 4 x i8> %vb, i8 %c) { 70; CHECK-LABEL: vmadd_vx_nxv4i8: 71; CHECK: # %bb.0: 72; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, mu 73; CHECK-NEXT: vmadd.vx v8, a0, v9 74; CHECK-NEXT: ret 75 %head = insertelement <vscale x 4 x i8> undef, i8 %c, i32 0 76 %splat = shufflevector <vscale x 4 x i8> %head, <vscale x 4 x i8> undef, <vscale x 4 x i32> zeroinitializer 77 %x = mul <vscale x 4 x i8> %va, %splat 78 %y = add <vscale x 4 x i8> %x, %vb 79 ret <vscale x 4 x i8> %y 80} 81 82define <vscale x 8 x i8> @vmadd_vv_nxv8i8(<vscale x 8 x i8> %va, <vscale x 8 x i8> %vb, <vscale x 8 x i8> %vc) { 83; CHECK-LABEL: vmadd_vv_nxv8i8: 84; CHECK: # %bb.0: 85; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, mu 86; CHECK-NEXT: vmacc.vv v8, v10, v9 87; CHECK-NEXT: ret 88 %x = mul <vscale x 8 x i8> %vb, %vc 89 %y = add <vscale x 8 x i8> %x, %va 90 ret <vscale x 8 x i8> %y 91} 92 93define <vscale x 8 x i8> @vmadd_vx_nxv8i8(<vscale x 8 x i8> %va, <vscale x 8 x i8> %vb, i8 %c) { 94; CHECK-LABEL: vmadd_vx_nxv8i8: 95; CHECK: # %bb.0: 96; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, mu 97; CHECK-NEXT: vmacc.vx v8, a0, v9 98; CHECK-NEXT: ret 99 %head = insertelement <vscale x 8 x i8> undef, i8 %c, i32 0 100 %splat = shufflevector <vscale x 8 x i8> %head, <vscale x 8 x i8> undef, <vscale x 8 x i32> zeroinitializer 101 %x = mul <vscale x 8 x i8> %vb, %splat 102 %y = add <vscale x 8 x i8> %x, %va 103 ret <vscale x 8 x i8> %y 104} 105 106define <vscale x 16 x i8> @vmadd_vv_nxv16i8(<vscale x 16 x i8> %va, <vscale x 16 x i8> %vb, <vscale x 16 x i8> %vc) { 107; CHECK-LABEL: vmadd_vv_nxv16i8: 108; CHECK: # %bb.0: 109; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, mu 110; CHECK-NEXT: vmadd.vv v8, v12, v10 111; CHECK-NEXT: ret 112 %x = mul <vscale x 16 x i8> %vc, %va 113 %y = add <vscale x 16 x i8> %x, %vb 114 ret <vscale x 16 x i8> %y 115} 116 117define <vscale x 16 x i8> @vmadd_vx_nxv16i8(<vscale x 16 x i8> %va, <vscale x 16 x i8> %vb, i8 %c) { 118; CHECK-LABEL: vmadd_vx_nxv16i8: 119; CHECK: # %bb.0: 120; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, mu 121; CHECK-NEXT: vmadd.vx v8, a0, v10 122; CHECK-NEXT: ret 123 %head = insertelement <vscale x 16 x i8> undef, i8 %c, i32 0 124 %splat = shufflevector <vscale x 16 x i8> %head, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer 125 %x = mul <vscale x 16 x i8> %va, %splat 126 %y = add <vscale x 16 x i8> %x, %vb 127 ret <vscale x 16 x i8> %y 128} 129 130define <vscale x 32 x i8> @vmadd_vv_nxv32i8(<vscale x 32 x i8> %va, <vscale x 32 x i8> %vb, <vscale x 32 x i8> %vc) { 131; CHECK-LABEL: vmadd_vv_nxv32i8: 132; CHECK: # %bb.0: 133; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, mu 134; CHECK-NEXT: vmacc.vv v8, v16, v12 135; CHECK-NEXT: ret 136 %x = mul <vscale x 32 x i8> %vc, %vb 137 %y = add <vscale x 32 x i8> %x, %va 138 ret <vscale x 32 x i8> %y 139} 140 141define <vscale x 32 x i8> @vmadd_vx_nxv32i8(<vscale x 32 x i8> %va, <vscale x 32 x i8> %vb, i8 %c) { 142; CHECK-LABEL: vmadd_vx_nxv32i8: 143; CHECK: # %bb.0: 144; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, mu 145; CHECK-NEXT: vmacc.vx v8, a0, v12 146; CHECK-NEXT: ret 147 %head = insertelement <vscale x 32 x i8> undef, i8 %c, i32 0 148 %splat = shufflevector <vscale x 32 x i8> %head, <vscale x 32 x i8> undef, <vscale x 32 x i32> zeroinitializer 149 %x = mul <vscale x 32 x i8> %vb, %splat 150 %y = add <vscale x 32 x i8> %x, %va 151 ret <vscale x 32 x i8> %y 152} 153 154define <vscale x 64 x i8> @vmadd_vv_nxv64i8(<vscale x 64 x i8> %va, <vscale x 64 x i8> %vb, <vscale x 64 x i8> %vc) { 155; CHECK-LABEL: vmadd_vv_nxv64i8: 156; CHECK: # %bb.0: 157; CHECK-NEXT: vl8r.v v24, (a0) 158; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, mu 159; CHECK-NEXT: vmacc.vv v8, v16, v24 160; CHECK-NEXT: ret 161 %x = mul <vscale x 64 x i8> %vc, %vb 162 %y = add <vscale x 64 x i8> %x, %va 163 ret <vscale x 64 x i8> %y 164} 165 166define <vscale x 64 x i8> @vmadd_vx_nxv64i8(<vscale x 64 x i8> %va, <vscale x 64 x i8> %vb, i8 %c) { 167; CHECK-LABEL: vmadd_vx_nxv64i8: 168; CHECK: # %bb.0: 169; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, mu 170; CHECK-NEXT: vmacc.vx v8, a0, v16 171; CHECK-NEXT: ret 172 %head = insertelement <vscale x 64 x i8> undef, i8 %c, i32 0 173 %splat = shufflevector <vscale x 64 x i8> %head, <vscale x 64 x i8> undef, <vscale x 64 x i32> zeroinitializer 174 %x = mul <vscale x 64 x i8> %vb, %splat 175 %y = add <vscale x 64 x i8> %x, %va 176 ret <vscale x 64 x i8> %y 177} 178 179define <vscale x 1 x i16> @vmadd_vv_nxv1i16(<vscale x 1 x i16> %va, <vscale x 1 x i16> %vb, <vscale x 1 x i16> %vc) { 180; CHECK-LABEL: vmadd_vv_nxv1i16: 181; CHECK: # %bb.0: 182; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, mu 183; CHECK-NEXT: vmadd.vv v8, v9, v10 184; CHECK-NEXT: ret 185 %x = mul <vscale x 1 x i16> %va, %vb 186 %y = add <vscale x 1 x i16> %x, %vc 187 ret <vscale x 1 x i16> %y 188} 189 190define <vscale x 1 x i16> @vmadd_vx_nxv1i16(<vscale x 1 x i16> %va, <vscale x 1 x i16> %vb, i16 %c) { 191; CHECK-LABEL: vmadd_vx_nxv1i16: 192; CHECK: # %bb.0: 193; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, mu 194; CHECK-NEXT: vmadd.vx v8, a0, v9 195; CHECK-NEXT: ret 196 %head = insertelement <vscale x 1 x i16> undef, i16 %c, i32 0 197 %splat = shufflevector <vscale x 1 x i16> %head, <vscale x 1 x i16> undef, <vscale x 1 x i32> zeroinitializer 198 %x = mul <vscale x 1 x i16> %va, %splat 199 %y = add <vscale x 1 x i16> %x, %vb 200 ret <vscale x 1 x i16> %y 201} 202 203define <vscale x 2 x i16> @vmadd_vv_nxv2i16(<vscale x 2 x i16> %va, <vscale x 2 x i16> %vb, <vscale x 2 x i16> %vc) { 204; CHECK-LABEL: vmadd_vv_nxv2i16: 205; CHECK: # %bb.0: 206; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, mu 207; CHECK-NEXT: vmadd.vv v8, v10, v9 208; CHECK-NEXT: ret 209 %x = mul <vscale x 2 x i16> %va, %vc 210 %y = add <vscale x 2 x i16> %x, %vb 211 ret <vscale x 2 x i16> %y 212} 213 214define <vscale x 2 x i16> @vmadd_vx_nxv2i16(<vscale x 2 x i16> %va, <vscale x 2 x i16> %vb, i16 %c) { 215; CHECK-LABEL: vmadd_vx_nxv2i16: 216; CHECK: # %bb.0: 217; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, mu 218; CHECK-NEXT: vmacc.vx v8, a0, v9 219; CHECK-NEXT: ret 220 %head = insertelement <vscale x 2 x i16> undef, i16 %c, i32 0 221 %splat = shufflevector <vscale x 2 x i16> %head, <vscale x 2 x i16> undef, <vscale x 2 x i32> zeroinitializer 222 %x = mul <vscale x 2 x i16> %vb, %splat 223 %y = add <vscale x 2 x i16> %x, %va 224 ret <vscale x 2 x i16> %y 225} 226 227define <vscale x 4 x i16> @vmadd_vv_nxv4i16(<vscale x 4 x i16> %va, <vscale x 4 x i16> %vb, <vscale x 4 x i16> %vc) { 228; CHECK-LABEL: vmadd_vv_nxv4i16: 229; CHECK: # %bb.0: 230; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, mu 231; CHECK-NEXT: vmadd.vv v8, v9, v10 232; CHECK-NEXT: ret 233 %x = mul <vscale x 4 x i16> %vb, %va 234 %y = add <vscale x 4 x i16> %x, %vc 235 ret <vscale x 4 x i16> %y 236} 237 238define <vscale x 4 x i16> @vmadd_vx_nxv4i16(<vscale x 4 x i16> %va, <vscale x 4 x i16> %vb, i16 %c) { 239; CHECK-LABEL: vmadd_vx_nxv4i16: 240; CHECK: # %bb.0: 241; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, mu 242; CHECK-NEXT: vmadd.vx v8, a0, v9 243; CHECK-NEXT: ret 244 %head = insertelement <vscale x 4 x i16> undef, i16 %c, i32 0 245 %splat = shufflevector <vscale x 4 x i16> %head, <vscale x 4 x i16> undef, <vscale x 4 x i32> zeroinitializer 246 %x = mul <vscale x 4 x i16> %va, %splat 247 %y = add <vscale x 4 x i16> %x, %vb 248 ret <vscale x 4 x i16> %y 249} 250 251define <vscale x 8 x i16> @vmadd_vv_nxv8i16(<vscale x 8 x i16> %va, <vscale x 8 x i16> %vb, <vscale x 8 x i16> %vc) { 252; CHECK-LABEL: vmadd_vv_nxv8i16: 253; CHECK: # %bb.0: 254; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, mu 255; CHECK-NEXT: vmacc.vv v8, v12, v10 256; CHECK-NEXT: ret 257 %x = mul <vscale x 8 x i16> %vb, %vc 258 %y = add <vscale x 8 x i16> %x, %va 259 ret <vscale x 8 x i16> %y 260} 261 262define <vscale x 8 x i16> @vmadd_vx_nxv8i16(<vscale x 8 x i16> %va, <vscale x 8 x i16> %vb, i16 %c) { 263; CHECK-LABEL: vmadd_vx_nxv8i16: 264; CHECK: # %bb.0: 265; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, mu 266; CHECK-NEXT: vmacc.vx v8, a0, v10 267; CHECK-NEXT: ret 268 %head = insertelement <vscale x 8 x i16> undef, i16 %c, i32 0 269 %splat = shufflevector <vscale x 8 x i16> %head, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer 270 %x = mul <vscale x 8 x i16> %vb, %splat 271 %y = add <vscale x 8 x i16> %x, %va 272 ret <vscale x 8 x i16> %y 273} 274 275define <vscale x 16 x i16> @vmadd_vv_nxv16i16(<vscale x 16 x i16> %va, <vscale x 16 x i16> %vb, <vscale x 16 x i16> %vc) { 276; CHECK-LABEL: vmadd_vv_nxv16i16: 277; CHECK: # %bb.0: 278; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, mu 279; CHECK-NEXT: vmadd.vv v8, v16, v12 280; CHECK-NEXT: ret 281 %x = mul <vscale x 16 x i16> %vc, %va 282 %y = add <vscale x 16 x i16> %x, %vb 283 ret <vscale x 16 x i16> %y 284} 285 286define <vscale x 16 x i16> @vmadd_vx_nxv16i16(<vscale x 16 x i16> %va, <vscale x 16 x i16> %vb, i16 %c) { 287; CHECK-LABEL: vmadd_vx_nxv16i16: 288; CHECK: # %bb.0: 289; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, mu 290; CHECK-NEXT: vmadd.vx v8, a0, v12 291; CHECK-NEXT: ret 292 %head = insertelement <vscale x 16 x i16> undef, i16 %c, i32 0 293 %splat = shufflevector <vscale x 16 x i16> %head, <vscale x 16 x i16> undef, <vscale x 16 x i32> zeroinitializer 294 %x = mul <vscale x 16 x i16> %va, %splat 295 %y = add <vscale x 16 x i16> %x, %vb 296 ret <vscale x 16 x i16> %y 297} 298 299define <vscale x 32 x i16> @vmadd_vv_nxv32i16(<vscale x 32 x i16> %va, <vscale x 32 x i16> %vb, <vscale x 32 x i16> %vc) { 300; CHECK-LABEL: vmadd_vv_nxv32i16: 301; CHECK: # %bb.0: 302; CHECK-NEXT: vl8re16.v v24, (a0) 303; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, mu 304; CHECK-NEXT: vmacc.vv v8, v16, v24 305; CHECK-NEXT: ret 306 %x = mul <vscale x 32 x i16> %vc, %vb 307 %y = add <vscale x 32 x i16> %x, %va 308 ret <vscale x 32 x i16> %y 309} 310 311define <vscale x 32 x i16> @vmadd_vx_nxv32i16(<vscale x 32 x i16> %va, <vscale x 32 x i16> %vb, i16 %c) { 312; CHECK-LABEL: vmadd_vx_nxv32i16: 313; CHECK: # %bb.0: 314; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, mu 315; CHECK-NEXT: vmacc.vx v8, a0, v16 316; CHECK-NEXT: ret 317 %head = insertelement <vscale x 32 x i16> undef, i16 %c, i32 0 318 %splat = shufflevector <vscale x 32 x i16> %head, <vscale x 32 x i16> undef, <vscale x 32 x i32> zeroinitializer 319 %x = mul <vscale x 32 x i16> %vb, %splat 320 %y = add <vscale x 32 x i16> %x, %va 321 ret <vscale x 32 x i16> %y 322} 323 324define <vscale x 1 x i32> @vmadd_vv_nxv1i32(<vscale x 1 x i32> %va, <vscale x 1 x i32> %vb, <vscale x 1 x i32> %vc) { 325; CHECK-LABEL: vmadd_vv_nxv1i32: 326; CHECK: # %bb.0: 327; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, mu 328; CHECK-NEXT: vmadd.vv v8, v9, v10 329; CHECK-NEXT: ret 330 %x = mul <vscale x 1 x i32> %va, %vb 331 %y = add <vscale x 1 x i32> %x, %vc 332 ret <vscale x 1 x i32> %y 333} 334 335define <vscale x 1 x i32> @vmadd_vx_nxv1i32(<vscale x 1 x i32> %va, <vscale x 1 x i32> %vb, i32 %c) { 336; CHECK-LABEL: vmadd_vx_nxv1i32: 337; CHECK: # %bb.0: 338; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, mu 339; CHECK-NEXT: vmadd.vx v8, a0, v9 340; CHECK-NEXT: ret 341 %head = insertelement <vscale x 1 x i32> undef, i32 %c, i32 0 342 %splat = shufflevector <vscale x 1 x i32> %head, <vscale x 1 x i32> undef, <vscale x 1 x i32> zeroinitializer 343 %x = mul <vscale x 1 x i32> %va, %splat 344 %y = add <vscale x 1 x i32> %x, %vb 345 ret <vscale x 1 x i32> %y 346} 347 348define <vscale x 2 x i32> @vmadd_vv_nxv2i32(<vscale x 2 x i32> %va, <vscale x 2 x i32> %vb, <vscale x 2 x i32> %vc) { 349; CHECK-LABEL: vmadd_vv_nxv2i32: 350; CHECK: # %bb.0: 351; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, mu 352; CHECK-NEXT: vmadd.vv v8, v10, v9 353; CHECK-NEXT: ret 354 %x = mul <vscale x 2 x i32> %va, %vc 355 %y = add <vscale x 2 x i32> %x, %vb 356 ret <vscale x 2 x i32> %y 357} 358 359define <vscale x 2 x i32> @vmadd_vx_nxv2i32(<vscale x 2 x i32> %va, <vscale x 2 x i32> %vb, i32 %c) { 360; CHECK-LABEL: vmadd_vx_nxv2i32: 361; CHECK: # %bb.0: 362; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, mu 363; CHECK-NEXT: vmacc.vx v8, a0, v9 364; CHECK-NEXT: ret 365 %head = insertelement <vscale x 2 x i32> undef, i32 %c, i32 0 366 %splat = shufflevector <vscale x 2 x i32> %head, <vscale x 2 x i32> undef, <vscale x 2 x i32> zeroinitializer 367 %x = mul <vscale x 2 x i32> %vb, %splat 368 %y = add <vscale x 2 x i32> %x, %va 369 ret <vscale x 2 x i32> %y 370} 371 372define <vscale x 4 x i32> @vmadd_vv_nxv4i32(<vscale x 4 x i32> %va, <vscale x 4 x i32> %vb, <vscale x 4 x i32> %vc) { 373; CHECK-LABEL: vmadd_vv_nxv4i32: 374; CHECK: # %bb.0: 375; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, mu 376; CHECK-NEXT: vmadd.vv v8, v10, v12 377; CHECK-NEXT: ret 378 %x = mul <vscale x 4 x i32> %vb, %va 379 %y = add <vscale x 4 x i32> %x, %vc 380 ret <vscale x 4 x i32> %y 381} 382 383define <vscale x 4 x i32> @vmadd_vx_nxv4i32(<vscale x 4 x i32> %va, <vscale x 4 x i32> %vb, i32 %c) { 384; CHECK-LABEL: vmadd_vx_nxv4i32: 385; CHECK: # %bb.0: 386; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, mu 387; CHECK-NEXT: vmadd.vx v8, a0, v10 388; CHECK-NEXT: ret 389 %head = insertelement <vscale x 4 x i32> undef, i32 %c, i32 0 390 %splat = shufflevector <vscale x 4 x i32> %head, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer 391 %x = mul <vscale x 4 x i32> %va, %splat 392 %y = add <vscale x 4 x i32> %x, %vb 393 ret <vscale x 4 x i32> %y 394} 395 396define <vscale x 8 x i32> @vmadd_vv_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i32> %vb, <vscale x 8 x i32> %vc) { 397; CHECK-LABEL: vmadd_vv_nxv8i32: 398; CHECK: # %bb.0: 399; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu 400; CHECK-NEXT: vmacc.vv v8, v16, v12 401; CHECK-NEXT: ret 402 %x = mul <vscale x 8 x i32> %vb, %vc 403 %y = add <vscale x 8 x i32> %x, %va 404 ret <vscale x 8 x i32> %y 405} 406 407define <vscale x 8 x i32> @vmadd_vx_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i32> %vb, i32 %c) { 408; CHECK-LABEL: vmadd_vx_nxv8i32: 409; CHECK: # %bb.0: 410; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu 411; CHECK-NEXT: vmacc.vx v8, a0, v12 412; CHECK-NEXT: ret 413 %head = insertelement <vscale x 8 x i32> undef, i32 %c, i32 0 414 %splat = shufflevector <vscale x 8 x i32> %head, <vscale x 8 x i32> undef, <vscale x 8 x i32> zeroinitializer 415 %x = mul <vscale x 8 x i32> %vb, %splat 416 %y = add <vscale x 8 x i32> %x, %va 417 ret <vscale x 8 x i32> %y 418} 419 420define <vscale x 16 x i32> @vmadd_vv_nxv16i32(<vscale x 16 x i32> %va, <vscale x 16 x i32> %vb, <vscale x 16 x i32> %vc) { 421; CHECK-LABEL: vmadd_vv_nxv16i32: 422; CHECK: # %bb.0: 423; CHECK-NEXT: vl8re32.v v24, (a0) 424; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, mu 425; CHECK-NEXT: vmadd.vv v8, v24, v16 426; CHECK-NEXT: ret 427 %x = mul <vscale x 16 x i32> %vc, %va 428 %y = add <vscale x 16 x i32> %x, %vb 429 ret <vscale x 16 x i32> %y 430} 431 432define <vscale x 16 x i32> @vmadd_vx_nxv16i32(<vscale x 16 x i32> %va, <vscale x 16 x i32> %vb, i32 %c) { 433; CHECK-LABEL: vmadd_vx_nxv16i32: 434; CHECK: # %bb.0: 435; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, mu 436; CHECK-NEXT: vmadd.vx v8, a0, v16 437; CHECK-NEXT: ret 438 %head = insertelement <vscale x 16 x i32> undef, i32 %c, i32 0 439 %splat = shufflevector <vscale x 16 x i32> %head, <vscale x 16 x i32> undef, <vscale x 16 x i32> zeroinitializer 440 %x = mul <vscale x 16 x i32> %va, %splat 441 %y = add <vscale x 16 x i32> %x, %vb 442 ret <vscale x 16 x i32> %y 443} 444 445define <vscale x 1 x i64> @vmadd_vv_nxv1i64(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb, <vscale x 1 x i64> %vc) { 446; CHECK-LABEL: vmadd_vv_nxv1i64: 447; CHECK: # %bb.0: 448; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, mu 449; CHECK-NEXT: vmadd.vv v8, v9, v10 450; CHECK-NEXT: ret 451 %x = mul <vscale x 1 x i64> %va, %vb 452 %y = add <vscale x 1 x i64> %x, %vc 453 ret <vscale x 1 x i64> %y 454} 455 456define <vscale x 1 x i64> @vmadd_vx_nxv1i64(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb, i64 %c) { 457; RV32-LABEL: vmadd_vx_nxv1i64: 458; RV32: # %bb.0: 459; RV32-NEXT: addi sp, sp, -16 460; RV32-NEXT: .cfi_def_cfa_offset 16 461; RV32-NEXT: sw a1, 12(sp) 462; RV32-NEXT: sw a0, 8(sp) 463; RV32-NEXT: vsetvli a0, zero, e64, m1, ta, mu 464; RV32-NEXT: addi a0, sp, 8 465; RV32-NEXT: vlse64.v v25, (a0), zero 466; RV32-NEXT: vmadd.vv v8, v25, v9 467; RV32-NEXT: addi sp, sp, 16 468; RV32-NEXT: ret 469; 470; RV64-LABEL: vmadd_vx_nxv1i64: 471; RV64: # %bb.0: 472; RV64-NEXT: vsetvli a1, zero, e64, m1, ta, mu 473; RV64-NEXT: vmadd.vx v8, a0, v9 474; RV64-NEXT: ret 475 %head = insertelement <vscale x 1 x i64> undef, i64 %c, i32 0 476 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> undef, <vscale x 1 x i32> zeroinitializer 477 %x = mul <vscale x 1 x i64> %va, %splat 478 %y = add <vscale x 1 x i64> %x, %vb 479 ret <vscale x 1 x i64> %y 480} 481 482define <vscale x 2 x i64> @vmadd_vv_nxv2i64(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb, <vscale x 2 x i64> %vc) { 483; CHECK-LABEL: vmadd_vv_nxv2i64: 484; CHECK: # %bb.0: 485; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, mu 486; CHECK-NEXT: vmadd.vv v8, v12, v10 487; CHECK-NEXT: ret 488 %x = mul <vscale x 2 x i64> %va, %vc 489 %y = add <vscale x 2 x i64> %x, %vb 490 ret <vscale x 2 x i64> %y 491} 492 493define <vscale x 2 x i64> @vmadd_vx_nxv2i64(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb, i64 %c) { 494; RV32-LABEL: vmadd_vx_nxv2i64: 495; RV32: # %bb.0: 496; RV32-NEXT: addi sp, sp, -16 497; RV32-NEXT: .cfi_def_cfa_offset 16 498; RV32-NEXT: sw a1, 12(sp) 499; RV32-NEXT: sw a0, 8(sp) 500; RV32-NEXT: vsetvli a0, zero, e64, m2, ta, mu 501; RV32-NEXT: addi a0, sp, 8 502; RV32-NEXT: vlse64.v v26, (a0), zero 503; RV32-NEXT: vmacc.vv v8, v10, v26 504; RV32-NEXT: addi sp, sp, 16 505; RV32-NEXT: ret 506; 507; RV64-LABEL: vmadd_vx_nxv2i64: 508; RV64: # %bb.0: 509; RV64-NEXT: vsetvli a1, zero, e64, m2, ta, mu 510; RV64-NEXT: vmacc.vx v8, a0, v10 511; RV64-NEXT: ret 512 %head = insertelement <vscale x 2 x i64> undef, i64 %c, i32 0 513 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer 514 %x = mul <vscale x 2 x i64> %vb, %splat 515 %y = add <vscale x 2 x i64> %x, %va 516 ret <vscale x 2 x i64> %y 517} 518 519define <vscale x 4 x i64> @vmadd_vv_nxv4i64(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb, <vscale x 4 x i64> %vc) { 520; CHECK-LABEL: vmadd_vv_nxv4i64: 521; CHECK: # %bb.0: 522; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, mu 523; CHECK-NEXT: vmadd.vv v8, v12, v16 524; CHECK-NEXT: ret 525 %x = mul <vscale x 4 x i64> %vb, %va 526 %y = add <vscale x 4 x i64> %x, %vc 527 ret <vscale x 4 x i64> %y 528} 529 530define <vscale x 4 x i64> @vmadd_vx_nxv4i64(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb, i64 %c) { 531; RV32-LABEL: vmadd_vx_nxv4i64: 532; RV32: # %bb.0: 533; RV32-NEXT: addi sp, sp, -16 534; RV32-NEXT: .cfi_def_cfa_offset 16 535; RV32-NEXT: sw a1, 12(sp) 536; RV32-NEXT: sw a0, 8(sp) 537; RV32-NEXT: vsetvli a0, zero, e64, m4, ta, mu 538; RV32-NEXT: addi a0, sp, 8 539; RV32-NEXT: vlse64.v v28, (a0), zero 540; RV32-NEXT: vmadd.vv v8, v28, v12 541; RV32-NEXT: addi sp, sp, 16 542; RV32-NEXT: ret 543; 544; RV64-LABEL: vmadd_vx_nxv4i64: 545; RV64: # %bb.0: 546; RV64-NEXT: vsetvli a1, zero, e64, m4, ta, mu 547; RV64-NEXT: vmadd.vx v8, a0, v12 548; RV64-NEXT: ret 549 %head = insertelement <vscale x 4 x i64> undef, i64 %c, i32 0 550 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> undef, <vscale x 4 x i32> zeroinitializer 551 %x = mul <vscale x 4 x i64> %va, %splat 552 %y = add <vscale x 4 x i64> %x, %vb 553 ret <vscale x 4 x i64> %y 554} 555 556define <vscale x 8 x i64> @vmadd_vv_nxv8i64(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb, <vscale x 8 x i64> %vc) { 557; CHECK-LABEL: vmadd_vv_nxv8i64: 558; CHECK: # %bb.0: 559; CHECK-NEXT: vl8re64.v v24, (a0) 560; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, mu 561; CHECK-NEXT: vmacc.vv v8, v16, v24 562; CHECK-NEXT: ret 563 %x = mul <vscale x 8 x i64> %vb, %vc 564 %y = add <vscale x 8 x i64> %x, %va 565 ret <vscale x 8 x i64> %y 566} 567 568define <vscale x 8 x i64> @vmadd_vx_nxv8i64(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb, i64 %c) { 569; RV32-LABEL: vmadd_vx_nxv8i64: 570; RV32: # %bb.0: 571; RV32-NEXT: addi sp, sp, -16 572; RV32-NEXT: .cfi_def_cfa_offset 16 573; RV32-NEXT: sw a1, 12(sp) 574; RV32-NEXT: sw a0, 8(sp) 575; RV32-NEXT: vsetvli a0, zero, e64, m8, ta, mu 576; RV32-NEXT: addi a0, sp, 8 577; RV32-NEXT: vlse64.v v24, (a0), zero 578; RV32-NEXT: vmacc.vv v8, v16, v24 579; RV32-NEXT: addi sp, sp, 16 580; RV32-NEXT: ret 581; 582; RV64-LABEL: vmadd_vx_nxv8i64: 583; RV64: # %bb.0: 584; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, mu 585; RV64-NEXT: vmacc.vx v8, a0, v16 586; RV64-NEXT: ret 587 %head = insertelement <vscale x 8 x i64> undef, i64 %c, i32 0 588 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> undef, <vscale x 8 x i32> zeroinitializer 589 %x = mul <vscale x 8 x i64> %vb, %splat 590 %y = add <vscale x 8 x i64> %x, %va 591 ret <vscale x 8 x i64> %y 592} 593