1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s | FileCheck %s
3 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck %s
5 ; Check that we perform binary arithmetic in a narrower type where possible, via
6 ; combineBinOpOfZExt or otherwise.
8 define <vscale x 8 x i32> @add(<vscale x 8 x i8> %a, <vscale x 8 x i8> %b) {
11 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
12 ; CHECK-NEXT: vwaddu.vv v12, v8, v9
13 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
14 ; CHECK-NEXT: vzext.vf2 v8, v12
16 %a.zext = zext <vscale x 8 x i8> %a to <vscale x 8 x i32>
17 %b.zext = zext <vscale x 8 x i8> %b to <vscale x 8 x i32>
18 %add = add <vscale x 8 x i32> %a.zext, %b.zext
19 ret <vscale x 8 x i32> %add
22 define <vscale x 8 x i32> @sub(<vscale x 8 x i8> %a, <vscale x 8 x i8> %b) {
25 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
26 ; CHECK-NEXT: vwsubu.vv v12, v8, v9
27 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
28 ; CHECK-NEXT: vsext.vf2 v8, v12
30 %a.zext = zext <vscale x 8 x i8> %a to <vscale x 8 x i32>
31 %b.zext = zext <vscale x 8 x i8> %b to <vscale x 8 x i32>
32 %sub = sub <vscale x 8 x i32> %a.zext, %b.zext
33 ret <vscale x 8 x i32> %sub
36 define <vscale x 8 x i32> @mul(<vscale x 8 x i8> %a, <vscale x 8 x i8> %b) {
39 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
40 ; CHECK-NEXT: vwmulu.vv v12, v8, v9
41 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
42 ; CHECK-NEXT: vzext.vf2 v8, v12
44 %a.zext = zext <vscale x 8 x i8> %a to <vscale x 8 x i32>
45 %b.zext = zext <vscale x 8 x i8> %b to <vscale x 8 x i32>
46 %mul = mul <vscale x 8 x i32> %a.zext, %b.zext
47 ret <vscale x 8 x i32> %mul
50 define <vscale x 8 x i32> @sdiv(<vscale x 8 x i8> %a, <vscale x 8 x i8> %b) {
53 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
54 ; CHECK-NEXT: vzext.vf2 v10, v9
55 ; CHECK-NEXT: vzext.vf2 v12, v8
56 ; CHECK-NEXT: vdivu.vv v12, v12, v10
57 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
58 ; CHECK-NEXT: vzext.vf2 v8, v12
60 %a.zext = zext <vscale x 8 x i8> %a to <vscale x 8 x i32>
61 %b.zext = zext <vscale x 8 x i8> %b to <vscale x 8 x i32>
62 %sdiv = sdiv <vscale x 8 x i32> %a.zext, %b.zext
63 ret <vscale x 8 x i32> %sdiv
66 define <vscale x 8 x i32> @udiv(<vscale x 8 x i8> %a, <vscale x 8 x i8> %b) {
69 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
70 ; CHECK-NEXT: vzext.vf2 v10, v9
71 ; CHECK-NEXT: vzext.vf2 v12, v8
72 ; CHECK-NEXT: vdivu.vv v12, v12, v10
73 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
74 ; CHECK-NEXT: vzext.vf2 v8, v12
76 %a.zext = zext <vscale x 8 x i8> %a to <vscale x 8 x i32>
77 %b.zext = zext <vscale x 8 x i8> %b to <vscale x 8 x i32>
78 %udiv = udiv <vscale x 8 x i32> %a.zext, %b.zext
79 ret <vscale x 8 x i32> %udiv
82 define <vscale x 8 x i32> @srem(<vscale x 8 x i8> %a, <vscale x 8 x i8> %b) {
85 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
86 ; CHECK-NEXT: vzext.vf2 v10, v9
87 ; CHECK-NEXT: vzext.vf2 v12, v8
88 ; CHECK-NEXT: vremu.vv v12, v12, v10
89 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
90 ; CHECK-NEXT: vzext.vf2 v8, v12
92 %a.zext = zext <vscale x 8 x i8> %a to <vscale x 8 x i32>
93 %b.zext = zext <vscale x 8 x i8> %b to <vscale x 8 x i32>
94 %srem = srem <vscale x 8 x i32> %a.zext, %b.zext
95 ret <vscale x 8 x i32> %srem
98 define <vscale x 8 x i32> @urem(<vscale x 8 x i8> %a, <vscale x 8 x i8> %b) {
101 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
102 ; CHECK-NEXT: vzext.vf2 v10, v9
103 ; CHECK-NEXT: vzext.vf2 v12, v8
104 ; CHECK-NEXT: vremu.vv v12, v12, v10
105 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
106 ; CHECK-NEXT: vzext.vf2 v8, v12
108 %a.zext = zext <vscale x 8 x i8> %a to <vscale x 8 x i32>
109 %b.zext = zext <vscale x 8 x i8> %b to <vscale x 8 x i32>
110 %urem = urem <vscale x 8 x i32> %a.zext, %b.zext
111 ret <vscale x 8 x i32> %urem
114 define <vscale x 8 x i32> @and(<vscale x 8 x i8> %a, <vscale x 8 x i8> %b) {
117 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
118 ; CHECK-NEXT: vand.vv v12, v8, v9
119 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
120 ; CHECK-NEXT: vzext.vf4 v8, v12
122 %a.zext = zext <vscale x 8 x i8> %a to <vscale x 8 x i32>
123 %b.zext = zext <vscale x 8 x i8> %b to <vscale x 8 x i32>
124 %shl = and <vscale x 8 x i32> %a.zext, %b.zext
125 ret <vscale x 8 x i32> %shl
128 define <vscale x 8 x i32> @or(<vscale x 8 x i8> %a, <vscale x 8 x i8> %b) {
131 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
132 ; CHECK-NEXT: vor.vv v12, v8, v9
133 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
134 ; CHECK-NEXT: vzext.vf4 v8, v12
136 %a.zext = zext <vscale x 8 x i8> %a to <vscale x 8 x i32>
137 %b.zext = zext <vscale x 8 x i8> %b to <vscale x 8 x i32>
138 %or = or <vscale x 8 x i32> %a.zext, %b.zext
139 ret <vscale x 8 x i32> %or
142 define <vscale x 8 x i32> @xor(<vscale x 8 x i8> %a, <vscale x 8 x i8> %b) {
145 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
146 ; CHECK-NEXT: vxor.vv v12, v8, v9
147 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
148 ; CHECK-NEXT: vzext.vf4 v8, v12
150 %a.zext = zext <vscale x 8 x i8> %a to <vscale x 8 x i32>
151 %b.zext = zext <vscale x 8 x i8> %b to <vscale x 8 x i32>
152 %xor = xor <vscale x 8 x i32> %a.zext, %b.zext
153 ret <vscale x 8 x i32> %xor