|
| 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 |
| 6 | + |
| 7 | +declare i64 @llvm.amdgcn.ballot.i64(i1) |
| 8 | +declare i64 @llvm.ctpop.i64(i64) |
| 9 | + |
| 10 | +; Test ballot(0) |
| 11 | + |
| 12 | +define amdgpu_cs i64 @constant_false() { |
| 13 | +; CHECK-LABEL: constant_false: |
| 14 | +; CHECK: ; %bb.0: |
| 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) |
| 19 | + ret i64 %ballot |
| 20 | +} |
| 21 | + |
| 22 | +; Test ballot(1) |
| 23 | + |
| 24 | +define amdgpu_cs i64 @constant_true() { |
| 25 | +; DAGISEL-LABEL: constant_true: |
| 26 | +; DAGISEL: ; %bb.0: |
| 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 |
| 30 | +; |
| 31 | +; GISEL-LABEL: constant_true: |
| 32 | +; GISEL: ; %bb.0: |
| 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) |
| 37 | + ret i64 %ballot |
| 38 | +} |
| 39 | + |
| 40 | +; Test ballot of a non-comparison operation |
| 41 | + |
| 42 | +define amdgpu_cs i64 @non_compare(i32 %x) { |
| 43 | +; CHECK-LABEL: non_compare: |
| 44 | +; CHECK: ; %bb.0: |
| 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) |
| 51 | + ret i64 %ballot |
| 52 | +} |
| 53 | + |
| 54 | +; Test ballot of comparisons |
| 55 | + |
| 56 | +define amdgpu_cs i64 @compare_ints(i32 %x, i32 %y) { |
| 57 | +; CHECK-LABEL: compare_ints: |
| 58 | +; CHECK: ; %bb.0: |
| 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) |
| 64 | + ret i64 %ballot |
| 65 | +} |
| 66 | + |
| 67 | +define amdgpu_cs i64 @compare_int_with_constant(i32 %x) { |
| 68 | +; DAGISEL-LABEL: compare_int_with_constant: |
| 69 | +; DAGISEL: ; %bb.0: |
| 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 |
| 73 | +; |
| 74 | +; GISEL-LABEL: compare_int_with_constant: |
| 75 | +; GISEL: ; %bb.0: |
| 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) |
| 81 | + ret i64 %ballot |
| 82 | +} |
| 83 | + |
| 84 | +define amdgpu_cs i64 @compare_floats(float %x, float %y) { |
| 85 | +; CHECK-LABEL: compare_floats: |
| 86 | +; CHECK: ; %bb.0: |
| 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) |
| 92 | + ret i64 %ballot |
| 93 | +} |
| 94 | + |
| 95 | +define amdgpu_cs i64 @ctpop_of_ballot(float %x, float %y) { |
| 96 | +; CHECK-LABEL: ctpop_of_ballot: |
| 97 | +; CHECK: ; %bb.0: |
| 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) |
| 105 | + ret i64 %bcnt |
| 106 | +} |
0 commit comments