Skip to content

Commit a5bc43e

Browse files
committed
[RISCV] Add new test for shouldNormalizeToSelectSequence variant
1 parent ca69a8d commit a5bc43e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

llvm/test/CodeGen/RISCV/zicond-opts.ll

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,35 @@ define i32 @icmp_and(i64 %x, i64 %y) {
2626
ret i32 %6
2727
}
2828

29+
; (and (icmp x. 0, ne), (icmp y, 0, ne)) -> (czero.eqz (icmp x, 0, ne), y)
30+
define i32 @icmp_and_select(i64 %x, i64 %y, i32 %z) {
31+
; RV32ZICOND-LABEL: icmp_and_select:
32+
; RV32ZICOND: # %bb.0:
33+
; RV32ZICOND-NEXT: sgtz a5, a3
34+
; RV32ZICOND-NEXT: snez a2, a2
35+
; RV32ZICOND-NEXT: or a0, a0, a1
36+
; RV32ZICOND-NEXT: czero.eqz a1, a5, a3
37+
; RV32ZICOND-NEXT: czero.nez a2, a2, a3
38+
; RV32ZICOND-NEXT: or a1, a2, a1
39+
; RV32ZICOND-NEXT: snez a0, a0
40+
; RV32ZICOND-NEXT: and a0, a0, a1
41+
; RV32ZICOND-NEXT: czero.eqz a0, a4, a0
42+
; RV32ZICOND-NEXT: ret
43+
;
44+
; RV64ZICOND-LABEL: icmp_and_select:
45+
; RV64ZICOND: # %bb.0:
46+
; RV64ZICOND-NEXT: sgtz a1, a1
47+
; RV64ZICOND-NEXT: snez a0, a0
48+
; RV64ZICOND-NEXT: and a0, a0, a1
49+
; RV64ZICOND-NEXT: czero.eqz a0, a2, a0
50+
; RV64ZICOND-NEXT: ret
51+
%3 = icmp sgt i64 %y, 0
52+
%4 = icmp ne i64 %x, 0
53+
%5 = and i1 %4, %3
54+
%6 = select i1 %5, i32 %z, i32 0
55+
ret i32 %6
56+
}
57+
2958
; (and (and (icmp x, 0, ne), (icmp y, 0, ne)), (icmp z, 0, ne)) -> (czero.eqz (czero.eqz (icmp x, 0, ne), y), z)
3059
define i32 @icmp_and_and(i64 %x, i64 %y, i64 %z) {
3160
; RV32ZICOND-LABEL: icmp_and_and:

0 commit comments

Comments
 (0)