1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -march=amdgcn -mcpu=gfx900 -global-isel -verify-machineinstrs < %s | FileCheck %s
4 declare i64 @llvm.amdgcn.ballot.i64(i1)
8 define amdgpu_cs i64 @constant_false() {
9 ; CHECK-LABEL: constant_false:
11 ; CHECK-NEXT: s_mov_b32 s0, 0
12 ; CHECK-NEXT: s_mov_b32 s1, 0
13 ; CHECK-NEXT: ; return to shader part epilog
14 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 0)
20 define amdgpu_cs i64 @constant_true() {
21 ; CHECK-LABEL: constant_true:
23 ; CHECK-NEXT: s_mov_b32 s0, exec_lo
24 ; CHECK-NEXT: s_mov_b32 s1, exec_hi
25 ; CHECK-NEXT: ; return to shader part epilog
26 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 1)
30 ; Test ballot of a non-comparison operation
32 define amdgpu_cs i64 @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 s[0:1], 0, v0
37 ; CHECK-NEXT: ; return to shader part epilog
38 %trunc = trunc i32 %x to i1
39 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %trunc)
43 ; Test ballot of comparisons
45 define amdgpu_cs i64 @compare_ints(i32 %x, i32 %y) {
46 ; CHECK-LABEL: compare_ints:
48 ; CHECK-NEXT: v_cmp_eq_u32_e64 s[0:1], v0, v1
49 ; CHECK-NEXT: ; return to shader part epilog
50 %cmp = icmp eq i32 %x, %y
51 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)
55 define amdgpu_cs i64 @compare_int_with_constant(i32 %x) {
56 ; CHECK-LABEL: compare_int_with_constant:
58 ; CHECK-NEXT: v_mov_b32_e32 v1, 0x63
59 ; CHECK-NEXT: v_cmp_ge_i32_e64 s[0:1], v0, v1
60 ; CHECK-NEXT: ; return to shader part epilog
61 %cmp = icmp sge i32 %x, 99
62 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)
66 define amdgpu_cs i64 @compare_floats(float %x, float %y) {
67 ; CHECK-LABEL: compare_floats:
69 ; CHECK-NEXT: v_cmp_gt_f32_e64 s[0:1], v0, v1
70 ; CHECK-NEXT: ; return to shader part epilog
71 %cmp = fcmp ogt float %x, %y
72 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)