1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=+wavefrontsize32,-wavefrontsize64 -global-isel -verify-machineinstrs < %s | FileCheck %s
3 ; RUN: llc -march=amdgcn -mcpu=gfx1100 -amdgpu-enable-delay-alu=0 -mattr=+wavefrontsize32,-wavefrontsize64 -global-isel -verify-machineinstrs < %s | FileCheck %s
5 declare i32 @llvm.amdgcn.ballot.i32(i1)
6 declare i32 @llvm.ctpop.i32(i32)
10 define amdgpu_cs i32 @constant_false() {
11 ; CHECK-LABEL: constant_false:
13 ; CHECK-NEXT: s_mov_b32 s0, 0
14 ; CHECK-NEXT: ; return to shader part epilog
15 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 0)
21 define amdgpu_cs i32 @constant_true() {
22 ; CHECK-LABEL: constant_true:
24 ; CHECK-NEXT: s_mov_b32 s0, exec_lo
25 ; CHECK-NEXT: ; return to shader part epilog
26 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 1)
30 ; Test ballot of a non-comparison operation
32 define amdgpu_cs i32 @non_compare(i32 %x) {
33 ; CHECK-LABEL: non_compare:
35 ; CHECK-NEXT: v_and_b32_e32 v0, 1, v0
36 ; CHECK-NEXT: v_cmp_ne_u32_e64 s0, 0, v0
37 ; CHECK-NEXT: ; return to shader part epilog
38 %trunc = trunc i32 %x to i1
39 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 %trunc)
43 ; Test ballot of comparisons
45 define amdgpu_cs i32 @compare_ints(i32 %x, i32 %y) {
46 ; CHECK-LABEL: compare_ints:
48 ; CHECK-NEXT: v_cmp_eq_u32_e64 s0, v0, v1
49 ; CHECK-NEXT: ; return to shader part epilog
50 %cmp = icmp eq i32 %x, %y
51 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 %cmp)
55 define amdgpu_cs i32 @compare_int_with_constant(i32 %x) {
56 ; CHECK-LABEL: compare_int_with_constant:
58 ; CHECK-NEXT: v_cmp_le_i32_e64 s0, 0x63, v0
59 ; CHECK-NEXT: ; return to shader part epilog
60 %cmp = icmp sge i32 %x, 99
61 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 %cmp)
65 define amdgpu_cs i32 @compare_floats(float %x, float %y) {
66 ; CHECK-LABEL: compare_floats:
68 ; CHECK-NEXT: v_cmp_gt_f32_e64 s0, v0, v1
69 ; CHECK-NEXT: ; return to shader part epilog
70 %cmp = fcmp ogt float %x, %y
71 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 %cmp)
75 define amdgpu_cs i32 @ctpop_of_ballot(float %x, float %y) {
76 ; CHECK-LABEL: ctpop_of_ballot:
78 ; CHECK-NEXT: v_cmp_gt_f32_e32 vcc_lo, v0, v1
79 ; CHECK-NEXT: s_bcnt1_i32_b32 s0, vcc_lo
80 ; CHECK-NEXT: ; return to shader part epilog
81 %cmp = fcmp ogt float %x, %y
82 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 %cmp)
83 %bcnt = call i32 @llvm.ctpop.i32(i32 %ballot)