Skip to content

Commit ec4dadb

Browse files
committed
[RISCV] Add tests where we aren't folding select with identity constant on RV64. NFC
1 parent 93c387d commit ec4dadb

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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 -check-prefixes=CHECK,RV32 %s
3+
; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck -check-prefixes=CHECK,RV64 %s
4+
5+
; The following binop x, (zext i1) tests will be vector-legalized into a vselect
6+
; of two splat_vectors, but on RV64 the splat value will be implicitly
7+
; truncated:
8+
;
9+
; t15: nxv2i32 = splat_vector Constant:i64<1>
10+
; t13: nxv2i32 = splat_vector Constant:i64<0>
11+
; t16: nxv2i32 = vselect t2, t15, t13
12+
; t7: nxv2i32 = add t4, t16
13+
;
14+
; Make sure that foldSelectWithIdentityConstant in DAGCombiner.cpp handles the
15+
; truncating splat, so we pull the vselect back and fold it into a mask.
16+
17+
define <vscale x 2 x i32> @i1_zext_add(<vscale x 2 x i1> %a, <vscale x 2 x i32> %b) {
18+
; RV32-LABEL: i1_zext_add:
19+
; RV32: # %bb.0:
20+
; RV32-NEXT: vsetvli a0, zero, e32, m1, ta, mu
21+
; RV32-NEXT: vadd.vi v8, v8, 1, v0.t
22+
; RV32-NEXT: ret
23+
;
24+
; RV64-LABEL: i1_zext_add:
25+
; RV64: # %bb.0:
26+
; RV64-NEXT: vsetvli a0, zero, e32, m1, ta, ma
27+
; RV64-NEXT: vmv.v.i v9, 0
28+
; RV64-NEXT: vmerge.vim v9, v9, 1, v0
29+
; RV64-NEXT: vadd.vv v8, v8, v9
30+
; RV64-NEXT: ret
31+
%zext = zext <vscale x 2 x i1> %a to <vscale x 2 x i32>
32+
%add = add <vscale x 2 x i32> %b, %zext
33+
ret <vscale x 2 x i32> %add
34+
}
35+
36+
define <vscale x 2 x i32> @i1_zext_add_commuted(<vscale x 2 x i1> %a, <vscale x 2 x i32> %b) {
37+
; RV32-LABEL: i1_zext_add_commuted:
38+
; RV32: # %bb.0:
39+
; RV32-NEXT: vsetvli a0, zero, e32, m1, ta, mu
40+
; RV32-NEXT: vadd.vi v8, v8, 1, v0.t
41+
; RV32-NEXT: ret
42+
;
43+
; RV64-LABEL: i1_zext_add_commuted:
44+
; RV64: # %bb.0:
45+
; RV64-NEXT: vsetvli a0, zero, e32, m1, ta, ma
46+
; RV64-NEXT: vmv.v.i v9, 0
47+
; RV64-NEXT: vmerge.vim v9, v9, 1, v0
48+
; RV64-NEXT: vadd.vv v8, v9, v8
49+
; RV64-NEXT: ret
50+
%zext = zext <vscale x 2 x i1> %a to <vscale x 2 x i32>
51+
%add = add <vscale x 2 x i32> %zext, %b
52+
ret <vscale x 2 x i32> %add
53+
}
54+
55+
define <vscale x 2 x i32> @i1_zext_sub(<vscale x 2 x i1> %a, <vscale x 2 x i32> %b) {
56+
; RV32-LABEL: i1_zext_sub:
57+
; RV32: # %bb.0:
58+
; RV32-NEXT: li a0, 1
59+
; RV32-NEXT: vsetvli a1, zero, e32, m1, ta, mu
60+
; RV32-NEXT: vsub.vx v8, v8, a0, v0.t
61+
; RV32-NEXT: ret
62+
;
63+
; RV64-LABEL: i1_zext_sub:
64+
; RV64: # %bb.0:
65+
; RV64-NEXT: vsetvli a0, zero, e32, m1, ta, ma
66+
; RV64-NEXT: vmv.v.i v9, 0
67+
; RV64-NEXT: vmerge.vim v9, v9, 1, v0
68+
; RV64-NEXT: vsub.vv v8, v8, v9
69+
; RV64-NEXT: ret
70+
%zext = zext <vscale x 2 x i1> %a to <vscale x 2 x i32>
71+
%sub = sub <vscale x 2 x i32> %b, %zext
72+
ret <vscale x 2 x i32> %sub
73+
}
74+
75+
define <vscale x 2 x i32> @i1_zext_or(<vscale x 2 x i1> %a, <vscale x 2 x i32> %b) {
76+
; RV32-LABEL: i1_zext_or:
77+
; RV32: # %bb.0:
78+
; RV32-NEXT: vsetvli a0, zero, e32, m1, ta, mu
79+
; RV32-NEXT: vor.vi v8, v8, 1, v0.t
80+
; RV32-NEXT: ret
81+
;
82+
; RV64-LABEL: i1_zext_or:
83+
; RV64: # %bb.0:
84+
; RV64-NEXT: vsetvli a0, zero, e32, m1, ta, ma
85+
; RV64-NEXT: vmv.v.i v9, 0
86+
; RV64-NEXT: vmerge.vim v9, v9, 1, v0
87+
; RV64-NEXT: vor.vv v8, v8, v9
88+
; RV64-NEXT: ret
89+
%zext = zext <vscale x 2 x i1> %a to <vscale x 2 x i32>
90+
%or = or <vscale x 2 x i32> %b, %zext
91+
ret <vscale x 2 x i32> %or
92+
}
93+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
94+
; CHECK: {{.*}}

0 commit comments

Comments
 (0)