1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -march=amdgcn -mcpu=gfx900 < %s | FileCheck %s
4 declare i64 @llvm.amdgcn.ballot.i64(i1)
5 declare i64 @llvm.ctpop.i64(i64)
9 define amdgpu_cs i64 @constant_false() {
10 ; CHECK-LABEL: constant_false:
12 ; CHECK-NEXT: s_mov_b32 s0, 0
13 ; CHECK-NEXT: s_mov_b32 s1, 0
14 ; CHECK-NEXT: ; return to shader part epilog
15 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 0)
21 define amdgpu_cs i64 @constant_true() {
22 ; CHECK-LABEL: constant_true:
24 ; CHECK-NEXT: s_mov_b32 s0, exec_lo
25 ; CHECK-NEXT: s_mov_b32 s1, exec_hi
26 ; CHECK-NEXT: ; return to shader part epilog
27 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 1)
31 ; Test ballot of a non-comparison operation
33 define amdgpu_cs i64 @non_compare(i32 %x) {
34 ; CHECK-LABEL: non_compare:
36 ; CHECK-NEXT: v_and_b32_e32 v0, 1, v0
37 ; CHECK-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v0
38 ; CHECK-NEXT: ; return to shader part epilog
39 %trunc = trunc i32 %x to i1
40 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %trunc)
44 ; Test ballot of comparisons
46 define amdgpu_cs i64 @compare_ints(i32 %x, i32 %y) {
47 ; CHECK-LABEL: compare_ints:
49 ; CHECK-NEXT: v_cmp_eq_u32_e64 s[0:1], v0, v1
50 ; CHECK-NEXT: ; return to shader part epilog
51 %cmp = icmp eq i32 %x, %y
52 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)
56 define amdgpu_cs i64 @compare_int_with_constant(i32 %x) {
57 ; CHECK-LABEL: compare_int_with_constant:
59 ; CHECK-NEXT: s_movk_i32 s0, 0x62
60 ; CHECK-NEXT: v_cmp_lt_i32_e64 s[0:1], s0, v0
61 ; CHECK-NEXT: ; return to shader part epilog
62 %cmp = icmp sge i32 %x, 99
63 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)
67 define amdgpu_cs i64 @compare_floats(float %x, float %y) {
68 ; CHECK-LABEL: compare_floats:
70 ; CHECK-NEXT: v_cmp_gt_f32_e64 s[0:1], v0, v1
71 ; CHECK-NEXT: ; return to shader part epilog
72 %cmp = fcmp ogt float %x, %y
73 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)
77 define amdgpu_cs i64 @ctpop_of_ballot(float %x, float %y) {
78 ; CHECK-LABEL: ctpop_of_ballot:
80 ; CHECK-NEXT: v_cmp_gt_f32_e32 vcc, v0, v1
81 ; CHECK-NEXT: s_bcnt1_i32_b64 s0, vcc
82 ; CHECK-NEXT: s_mov_b32 s1, 0
83 ; CHECK-NEXT: ; return to shader part epilog
84 %cmp = fcmp ogt float %x, %y
85 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)
86 %bcnt = call i64 @llvm.ctpop.i64(i64 %ballot)