1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+m,+v < %s | FileCheck %s --check-prefix=RV32
3 ; RUN: llc -mtriple=riscv64 -mattr=+m,+v < %s | FileCheck %s --check-prefix=RV64
5 define <vscale x 1 x i16> @test_urem_vec_even_divisor_eq0(<vscale x 1 x i16> %x) nounwind {
6 ; RV32-LABEL: test_urem_vec_even_divisor_eq0:
8 ; RV32-NEXT: lui a0, 1048571
9 ; RV32-NEXT: addi a0, a0, -1365
10 ; RV32-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
11 ; RV32-NEXT: vmul.vx v8, v8, a0
12 ; RV32-NEXT: vsll.vi v9, v8, 15
13 ; RV32-NEXT: vsrl.vi v8, v8, 1
14 ; RV32-NEXT: vor.vv v8, v8, v9
15 ; RV32-NEXT: lui a0, 3
16 ; RV32-NEXT: addi a0, a0, -1366
17 ; RV32-NEXT: vmsgtu.vx v0, v8, a0
18 ; RV32-NEXT: vmv.v.i v8, 0
19 ; RV32-NEXT: vmerge.vim v8, v8, -1, v0
22 ; RV64-LABEL: test_urem_vec_even_divisor_eq0:
24 ; RV64-NEXT: lui a0, 1048571
25 ; RV64-NEXT: addi a0, a0, -1365
26 ; RV64-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
27 ; RV64-NEXT: vmul.vx v8, v8, a0
28 ; RV64-NEXT: vsll.vi v9, v8, 15
29 ; RV64-NEXT: vsrl.vi v8, v8, 1
30 ; RV64-NEXT: vor.vv v8, v8, v9
31 ; RV64-NEXT: lui a0, 3
32 ; RV64-NEXT: addi a0, a0, -1366
33 ; RV64-NEXT: vmsgtu.vx v0, v8, a0
34 ; RV64-NEXT: vmv.v.i v8, 0
35 ; RV64-NEXT: vmerge.vim v8, v8, -1, v0
37 %ins1 = insertelement <vscale x 1 x i16> poison, i16 6, i32 0
38 %splat1 = shufflevector <vscale x 1 x i16> %ins1, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
39 %urem = urem <vscale x 1 x i16> %x, %splat1
40 %ins2 = insertelement <vscale x 1 x i16> poison, i16 0, i32 0
41 %splat2 = shufflevector <vscale x 1 x i16> %ins2, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
42 %cmp = icmp ne <vscale x 1 x i16> %urem, %splat2
43 %ext = sext <vscale x 1 x i1> %cmp to <vscale x 1 x i16>
44 ret <vscale x 1 x i16> %ext
47 define <vscale x 1 x i16> @test_urem_vec_odd_divisor_eq0(<vscale x 1 x i16> %x) nounwind {
48 ; RV32-LABEL: test_urem_vec_odd_divisor_eq0:
50 ; RV32-NEXT: lui a0, 1048573
51 ; RV32-NEXT: addi a0, a0, -819
52 ; RV32-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
53 ; RV32-NEXT: vmul.vx v8, v8, a0
54 ; RV32-NEXT: lui a0, 3
55 ; RV32-NEXT: addi a0, a0, 819
56 ; RV32-NEXT: vmsgtu.vx v0, v8, a0
57 ; RV32-NEXT: vmv.v.i v8, 0
58 ; RV32-NEXT: vmerge.vim v8, v8, -1, v0
61 ; RV64-LABEL: test_urem_vec_odd_divisor_eq0:
63 ; RV64-NEXT: lui a0, 1048573
64 ; RV64-NEXT: addi a0, a0, -819
65 ; RV64-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
66 ; RV64-NEXT: vmul.vx v8, v8, a0
67 ; RV64-NEXT: lui a0, 3
68 ; RV64-NEXT: addi a0, a0, 819
69 ; RV64-NEXT: vmsgtu.vx v0, v8, a0
70 ; RV64-NEXT: vmv.v.i v8, 0
71 ; RV64-NEXT: vmerge.vim v8, v8, -1, v0
73 %ins1 = insertelement <vscale x 1 x i16> poison, i16 5, i32 0
74 %splat1 = shufflevector <vscale x 1 x i16> %ins1, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
75 %urem = urem <vscale x 1 x i16> %x, %splat1
76 %ins2 = insertelement <vscale x 1 x i16> poison, i16 0, i32 0
77 %splat2 = shufflevector <vscale x 1 x i16> %ins2, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
78 %cmp = icmp ne <vscale x 1 x i16> %urem, %splat2
79 %ext = sext <vscale x 1 x i1> %cmp to <vscale x 1 x i16>
80 ret <vscale x 1 x i16> %ext
83 define <vscale x 1 x i16> @test_urem_vec_even_divisor_eq1(<vscale x 1 x i16> %x) nounwind {
84 ; RV32-LABEL: test_urem_vec_even_divisor_eq1:
87 ; RV32-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
88 ; RV32-NEXT: vsub.vx v8, v8, a0
89 ; RV32-NEXT: lui a0, 1048571
90 ; RV32-NEXT: addi a0, a0, -1365
91 ; RV32-NEXT: vmul.vx v8, v8, a0
92 ; RV32-NEXT: vsll.vi v9, v8, 15
93 ; RV32-NEXT: vsrl.vi v8, v8, 1
94 ; RV32-NEXT: vor.vv v8, v8, v9
95 ; RV32-NEXT: lui a0, 3
96 ; RV32-NEXT: addi a0, a0, -1366
97 ; RV32-NEXT: vmsgtu.vx v0, v8, a0
98 ; RV32-NEXT: vmv.v.i v8, 0
99 ; RV32-NEXT: vmerge.vim v8, v8, -1, v0
102 ; RV64-LABEL: test_urem_vec_even_divisor_eq1:
104 ; RV64-NEXT: li a0, 1
105 ; RV64-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
106 ; RV64-NEXT: vsub.vx v8, v8, a0
107 ; RV64-NEXT: lui a0, 1048571
108 ; RV64-NEXT: addi a0, a0, -1365
109 ; RV64-NEXT: vmul.vx v8, v8, a0
110 ; RV64-NEXT: vsll.vi v9, v8, 15
111 ; RV64-NEXT: vsrl.vi v8, v8, 1
112 ; RV64-NEXT: vor.vv v8, v8, v9
113 ; RV64-NEXT: lui a0, 3
114 ; RV64-NEXT: addi a0, a0, -1366
115 ; RV64-NEXT: vmsgtu.vx v0, v8, a0
116 ; RV64-NEXT: vmv.v.i v8, 0
117 ; RV64-NEXT: vmerge.vim v8, v8, -1, v0
119 %ins1 = insertelement <vscale x 1 x i16> poison, i16 6, i32 0
120 %splat1 = shufflevector <vscale x 1 x i16> %ins1, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
121 %urem = urem <vscale x 1 x i16> %x, %splat1
122 %ins2 = insertelement <vscale x 1 x i16> poison, i16 1, i32 0
123 %splat2 = shufflevector <vscale x 1 x i16> %ins2, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
124 %cmp = icmp ne <vscale x 1 x i16> %urem, %splat2
125 %ext = sext <vscale x 1 x i1> %cmp to <vscale x 1 x i16>
126 ret <vscale x 1 x i16> %ext
129 define <vscale x 1 x i16> @test_urem_vec_odd_divisor_eq1(<vscale x 1 x i16> %x) nounwind {
130 ; RV32-LABEL: test_urem_vec_odd_divisor_eq1:
132 ; RV32-NEXT: li a0, 1
133 ; RV32-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
134 ; RV32-NEXT: vsub.vx v8, v8, a0
135 ; RV32-NEXT: lui a0, 1048573
136 ; RV32-NEXT: addi a0, a0, -819
137 ; RV32-NEXT: vmul.vx v8, v8, a0
138 ; RV32-NEXT: lui a0, 3
139 ; RV32-NEXT: addi a0, a0, 818
140 ; RV32-NEXT: vmsgtu.vx v0, v8, a0
141 ; RV32-NEXT: vmv.v.i v8, 0
142 ; RV32-NEXT: vmerge.vim v8, v8, -1, v0
145 ; RV64-LABEL: test_urem_vec_odd_divisor_eq1:
147 ; RV64-NEXT: li a0, 1
148 ; RV64-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
149 ; RV64-NEXT: vsub.vx v8, v8, a0
150 ; RV64-NEXT: lui a0, 1048573
151 ; RV64-NEXT: addi a0, a0, -819
152 ; RV64-NEXT: vmul.vx v8, v8, a0
153 ; RV64-NEXT: lui a0, 3
154 ; RV64-NEXT: addi a0, a0, 818
155 ; RV64-NEXT: vmsgtu.vx v0, v8, a0
156 ; RV64-NEXT: vmv.v.i v8, 0
157 ; RV64-NEXT: vmerge.vim v8, v8, -1, v0
159 %ins1 = insertelement <vscale x 1 x i16> poison, i16 5, i32 0
160 %splat1 = shufflevector <vscale x 1 x i16> %ins1, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
161 %urem = urem <vscale x 1 x i16> %x, %splat1
162 %ins2 = insertelement <vscale x 1 x i16> poison, i16 1, i32 0
163 %splat2 = shufflevector <vscale x 1 x i16> %ins2, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
164 %cmp = icmp ne <vscale x 1 x i16> %urem, %splat2
165 %ext = sext <vscale x 1 x i1> %cmp to <vscale x 1 x i16>
166 ret <vscale x 1 x i16> %ext