Skip to content

Commit f5f9d07

Browse files
committed
add tests
1 parent a2d8f8d commit f5f9d07

File tree

1 file changed

+47
-28
lines changed

1 file changed

+47
-28
lines changed

test/codegen/zicond.go

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,67 @@
77
package codegen
88

99
//go:noinline
10-
func testIfxZero(a, b int) int {
11-
r := b
10+
func testNoZicondUnderRva20u64(a, b int) int {
11+
result := b
1212
if a == 0 {
13-
r = a
13+
result = a
14+
}
15+
// riscv64/rva20u64:-`CZEROEQZ`, -`CZERONEZ`
16+
return result
17+
}
18+
19+
//go:noinline
20+
func testNoZicondUnderRva22u64(a, b int) int {
21+
result := b
22+
if a == 0 {
23+
result = a
24+
}
25+
// riscv64/rva22u64:-`CZEROEQZ`, -`CZERONEZ`
26+
return result
27+
}
28+
29+
//go:noinline
30+
func testGenZicondUnderRva23u64(a, b int) int {
31+
result := b
32+
if a == 0 {
33+
result = a
1434
}
1535
// riscv64/rva23u64:`CZEROEQZ`, -`CZERONEZ`
16-
return r
36+
return result
1737
}
1838

1939
//go:noinline
20-
func testZicond(a, b int) int {
21-
var c int
40+
func testGenZicond(a, b int) int {
41+
var result int
2242
if a > b {
23-
c = a
43+
result = a
2444
} else {
25-
c = b
45+
result = b
2646
}
2747
// riscv64/rva23u64:`CZERONEZ`,`CZEROEQZ`
28-
return c
48+
return result
2949
}
3050

3151
//go:noinline
3252
func selectIfZero(cond, a, b int) int {
33-
r := a
53+
result := a
3454
if cond == 0 {
35-
r = b
55+
result = b
3656
}
3757
// riscv64/rva23u64:`CZERONEZ`,`CZEROEQZ`, `OR`
3858
// riscv64/rva23u64:-`SEQZ`
39-
return r
59+
return result
4060
}
4161

4262
//go:noinline
4363
func testSelectIfNotZero(cond, a, b int) int {
44-
r := a
64+
result := a
4565
if cond != 0 {
46-
r = b
66+
result = b
4767
}
4868
// riscv64/rva23u64:`CZERONEZ`,`CZEROEQZ`, `OR`
4969
// riscv64/rva23u64:-`SNEZ`
50-
return r
70+
return result
5171
}
5272

5373
//go:noinline
@@ -60,7 +80,7 @@ func testCondAddZero(cond, a, b int) int {
6080
// riscv64/rva23u64:-`SEQZ`, -`CZEROEQZ`, -`OR`
6181
return result
6282
}
63-
83+
6484
//go:noinline
6585
func testCondAddNonZero(cond, a, b int) int {
6686
var result int
@@ -102,11 +122,11 @@ func testCondSubNonZero(cond, a, b int) int {
102122

103123
//go:noinline
104124
func testCondOrZero(cond, a, b int) int {
105-
var result int
106-
if cond == 0 {
125+
var result int
126+
if cond == 0 {
107127
result = a | b
108-
} else {
109-
result = a
128+
} else {
129+
result = a
110130
}
111131
// riscv64/rva23u64:`CZERONEZ`, `OR`
112132
// riscv64/rva23u64:-`SEQZ`, -`CZEROEQZ`
@@ -115,16 +135,16 @@ func testCondOrZero(cond, a, b int) int {
115135

116136
//go:noinline
117137
func testCondOrNonZero(cond, a, b int) int {
118-
var result int
119-
if cond != 0 {
138+
var result int
139+
if cond != 0 {
120140
result = a | b
121-
} else {
122-
result = a
141+
} else {
142+
result = a
123143
}
124144
// riscv64/rva23u64:`CZEROEQZ`, `OR`
125145
// riscv64/rva23u64:-`SNEZ`, -`CZERONEZ`
126146
return result
127-
}
147+
}
128148

129149
//go:noinline
130150
func testCondXorZero(cond, a, b int) int {
@@ -138,7 +158,7 @@ func testCondXorZero(cond, a, b int) int {
138158
// riscv64/rva23u64:-`SEQZ`, -`CZEROEQZ`, -`OR`
139159
return result
140160
}
141-
161+
142162
//go:noinline
143163
func testCondXorNonZero(cond, a, b int) int {
144164
var result int
@@ -164,7 +184,7 @@ func testCondAndZero(cond, a, b int) int {
164184
// riscv64/rva23u64:-`SEQZ`, -`CZERONEZ`
165185
return result
166186
}
167-
187+
168188
//go:noinline
169189
func testCondAndNonZero(cond, a, b int) int {
170190
var result int
@@ -177,4 +197,3 @@ func testCondAndNonZero(cond, a, b int) int {
177197
// riscv64/rva23u64:-`SNEZ`, -`CZEROEQZ`
178198
return result
179199
}
180-

0 commit comments

Comments
 (0)