1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=+wavefrontsize32,-wavefrontsize64 < %s | FileCheck %s 3 4declare i32 @llvm.amdgcn.ballot.i32(i1) 5 6; Test ballot(0) 7 8define amdgpu_cs i32 @constant_false() { 9; CHECK-LABEL: constant_false: 10; CHECK: ; %bb.0: 11; CHECK-NEXT: s_mov_b32 s0, 0 12; CHECK-NEXT: ; return to shader part epilog 13 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 0) 14 ret i32 %ballot 15} 16 17; Test ballot(1) 18 19define amdgpu_cs i32 @constant_true() { 20; CHECK-LABEL: constant_true: 21; CHECK: ; %bb.0: 22; CHECK-NEXT: s_mov_b32 s0, exec_lo 23; CHECK-NEXT: ; return to shader part epilog 24 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 1) 25 ret i32 %ballot 26} 27 28; Test ballot of a non-comparison operation 29 30define amdgpu_cs i32 @non_compare(i32 %x) { 31; CHECK-LABEL: non_compare: 32; CHECK: ; %bb.0: 33; CHECK-NEXT: v_and_b32_e32 v0, 1, v0 34; CHECK-NEXT: v_cmp_ne_u32_e64 s0, 0, v0 35; CHECK-NEXT: ; return to shader part epilog 36 %trunc = trunc i32 %x to i1 37 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 %trunc) 38 ret i32 %ballot 39} 40 41; Test ballot of comparisons 42 43define amdgpu_cs i32 @compare_ints(i32 %x, i32 %y) { 44; CHECK-LABEL: compare_ints: 45; CHECK: ; %bb.0: 46; CHECK-NEXT: v_cmp_eq_u32_e64 s0, v0, v1 47; CHECK-NEXT: ; return to shader part epilog 48 %cmp = icmp eq i32 %x, %y 49 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 %cmp) 50 ret i32 %ballot 51} 52 53define amdgpu_cs i32 @compare_int_with_constant(i32 %x) { 54; CHECK-LABEL: compare_int_with_constant: 55; CHECK: ; %bb.0: 56; CHECK-NEXT: v_cmp_lt_i32_e64 s0, 0x62, v0 57; CHECK-NEXT: ; return to shader part epilog 58 %cmp = icmp sge i32 %x, 99 59 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 %cmp) 60 ret i32 %ballot 61} 62 63define amdgpu_cs i32 @compare_floats(float %x, float %y) { 64; CHECK-LABEL: compare_floats: 65; CHECK: ; %bb.0: 66; CHECK-NEXT: v_cmp_gt_f32_e64 s0, v0, v1 67; CHECK-NEXT: ; return to shader part epilog 68 %cmp = fcmp ogt float %x, %y 69 %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 %cmp) 70 ret i32 %ballot 71} 72