1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -march=amdgcn -global-isel=0 -mcpu=gfx1010 < %s | FileCheck %s --check-prefixes=CHECK,DAGISEL
3 ; RUN: llc -march=amdgcn -global-isel=0 -mcpu=gfx1100 -amdgpu-enable-delay-alu=0 < %s | FileCheck %s --check-prefixes=CHECK,DAGISEL
4 ; RUN: llc -march=amdgcn -global-isel -mcpu=gfx1010 < %s | FileCheck %s --check-prefixes=CHECK,GISEL
5 ; RUN: llc -march=amdgcn -global-isel -mcpu=gfx1100 -amdgpu-enable-delay-alu=0 < %s | FileCheck %s --check-prefixes=CHECK,GISEL
7 declare i64 @llvm.amdgcn.ballot.i64(i1)
8 declare i64 @llvm.ctpop.i64(i64)
12 define amdgpu_cs i64 @constant_false() {
13 ; CHECK-LABEL: constant_false:
15 ; CHECK-NEXT: s_mov_b32 s0, 0
16 ; CHECK-NEXT: s_mov_b32 s1, 0
17 ; CHECK-NEXT: ; return to shader part epilog
18 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 0)
24 define amdgpu_cs i64 @constant_true() {
25 ; DAGISEL-LABEL: constant_true:
27 ; DAGISEL-NEXT: s_mov_b32 s0, exec_lo
28 ; DAGISEL-NEXT: s_mov_b32 s1, exec_hi
29 ; DAGISEL-NEXT: ; return to shader part epilog
31 ; GISEL-LABEL: constant_true:
33 ; GISEL-NEXT: s_mov_b32 s0, exec_lo
34 ; GISEL-NEXT: s_mov_b32 s1, 0
35 ; GISEL-NEXT: ; return to shader part epilog
36 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 1)
40 ; Test ballot of a non-comparison operation
42 define amdgpu_cs i64 @non_compare(i32 %x) {
43 ; CHECK-LABEL: non_compare:
45 ; CHECK-NEXT: v_and_b32_e32 v0, 1, v0
46 ; CHECK-NEXT: s_mov_b32 s1, 0
47 ; CHECK-NEXT: v_cmp_ne_u32_e64 s0, 0, v0
48 ; CHECK-NEXT: ; return to shader part epilog
49 %trunc = trunc i32 %x to i1
50 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %trunc)
54 ; Test ballot of comparisons
56 define amdgpu_cs i64 @compare_ints(i32 %x, i32 %y) {
57 ; CHECK-LABEL: compare_ints:
59 ; CHECK-NEXT: v_cmp_eq_u32_e64 s0, v0, v1
60 ; CHECK-NEXT: s_mov_b32 s1, 0
61 ; CHECK-NEXT: ; return to shader part epilog
62 %cmp = icmp eq i32 %x, %y
63 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)
67 define amdgpu_cs i64 @compare_int_with_constant(i32 %x) {
68 ; DAGISEL-LABEL: compare_int_with_constant:
70 ; DAGISEL-NEXT: v_cmp_lt_i32_e64 s0, 0x62, v0
71 ; DAGISEL-NEXT: s_mov_b32 s1, 0
72 ; DAGISEL-NEXT: ; return to shader part epilog
74 ; GISEL-LABEL: compare_int_with_constant:
76 ; GISEL-NEXT: v_cmp_le_i32_e64 s0, 0x63, v0
77 ; GISEL-NEXT: s_mov_b32 s1, 0
78 ; GISEL-NEXT: ; return to shader part epilog
79 %cmp = icmp sge i32 %x, 99
80 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)
84 define amdgpu_cs i64 @compare_floats(float %x, float %y) {
85 ; CHECK-LABEL: compare_floats:
87 ; CHECK-NEXT: v_cmp_gt_f32_e64 s0, v0, v1
88 ; CHECK-NEXT: s_mov_b32 s1, 0
89 ; CHECK-NEXT: ; return to shader part epilog
90 %cmp = fcmp ogt float %x, %y
91 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)
95 define amdgpu_cs i64 @ctpop_of_ballot(float %x, float %y) {
96 ; CHECK-LABEL: ctpop_of_ballot:
98 ; CHECK-NEXT: v_cmp_gt_f32_e64 s0, v0, v1
99 ; CHECK-NEXT: s_mov_b32 s1, 0
100 ; CHECK-NEXT: s_bcnt1_i32_b64 s0, s[0:1]
101 ; CHECK-NEXT: ; return to shader part epilog
102 %cmp = fcmp ogt float %x, %y
103 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)
104 %bcnt = call i64 @llvm.ctpop.i64(i64 %ballot)