1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=1 | FileCheck %s --check-prefixes=NO_FOLDING
3 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=1 | FileCheck %s --check-prefixes=NO_FOLDING
4 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=2 | FileCheck %s --check-prefixes=NO_FOLDING
5 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=2 | FileCheck %s --check-prefixes=NO_FOLDING
6 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=3 | FileCheck %s --check-prefixes=FOLDING
7 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=3 | FileCheck %s --check-prefixes=FOLDING
8 ; Check that the default value enables the web folding and
9 ; that it is bigger than 3.
10 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=FOLDING
11 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=FOLDING
14 ; Check that the add/sub/mul operations are all promoted into their
15 ; vw counterpart when the folding of the web size is increased to 3.
16 ; We need the web size to be at least 3 for the folding to happen, because
18 define <2 x i16> @vwmul_v2i16_multiple_users(ptr %x, ptr %y, ptr %z) {
19 ; NO_FOLDING-LABEL: vwmul_v2i16_multiple_users:
20 ; NO_FOLDING: # %bb.0:
21 ; NO_FOLDING-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
22 ; NO_FOLDING-NEXT: vle8.v v8, (a0)
23 ; NO_FOLDING-NEXT: vle8.v v9, (a1)
24 ; NO_FOLDING-NEXT: vle8.v v10, (a2)
25 ; NO_FOLDING-NEXT: vsext.vf2 v11, v8
26 ; NO_FOLDING-NEXT: vsext.vf2 v8, v9
27 ; NO_FOLDING-NEXT: vsext.vf2 v9, v10
28 ; NO_FOLDING-NEXT: vmul.vv v8, v11, v8
29 ; NO_FOLDING-NEXT: vadd.vv v10, v11, v9
30 ; NO_FOLDING-NEXT: vsub.vv v9, v11, v9
31 ; NO_FOLDING-NEXT: vor.vv v8, v8, v10
32 ; NO_FOLDING-NEXT: vor.vv v8, v8, v9
33 ; NO_FOLDING-NEXT: ret
35 ; FOLDING-LABEL: vwmul_v2i16_multiple_users:
37 ; FOLDING-NEXT: vsetivli zero, 2, e8, mf8, ta, ma
38 ; FOLDING-NEXT: vle8.v v8, (a0)
39 ; FOLDING-NEXT: vle8.v v9, (a1)
40 ; FOLDING-NEXT: vle8.v v10, (a2)
41 ; FOLDING-NEXT: vwmul.vv v11, v8, v9
42 ; FOLDING-NEXT: vwadd.vv v9, v8, v10
43 ; FOLDING-NEXT: vwsub.vv v12, v8, v10
44 ; FOLDING-NEXT: vsetvli zero, zero, e16, mf4, ta, ma
45 ; FOLDING-NEXT: vor.vv v8, v11, v9
46 ; FOLDING-NEXT: vor.vv v8, v8, v12
48 %a = load <2 x i8>, ptr %x
49 %b = load <2 x i8>, ptr %y
50 %b2 = load <2 x i8>, ptr %z
51 %c = sext <2 x i8> %a to <2 x i16>
52 %d = sext <2 x i8> %b to <2 x i16>
53 %d2 = sext <2 x i8> %b2 to <2 x i16>
54 %e = mul <2 x i16> %c, %d
55 %f = add <2 x i16> %c, %d2
56 %g = sub <2 x i16> %c, %d2
57 %h = or <2 x i16> %e, %f
58 %i = or <2 x i16> %h, %g