198 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc -mtriple=amdgcn -global-isel=0 -mcpu=gfx1010 < %s | FileCheck %s --check-prefixes=CHECK,DAGISEL3; RUN: llc -mtriple=amdgcn -global-isel=0 -mcpu=gfx1100 -mattr=+real-true16 -amdgpu-enable-delay-alu=0 < %s | FileCheck %s --check-prefixes=CHECK,DAGISEL,DAGISEL-TRUE164; RUN: llc -mtriple=amdgcn -global-isel=0 -mcpu=gfx1100 -mattr=-real-true16 -amdgpu-enable-delay-alu=0 < %s | FileCheck %s --check-prefixes=CHECK,DAGISEL,DAGISEL-FAKE165; RUN: llc -mtriple=amdgcn -global-isel -mcpu=gfx1010 < %s | FileCheck %s --check-prefixes=CHECK,GISEL6; RUN: llc -mtriple=amdgcn -global-isel -mcpu=gfx1100 -mattr=+real-true16 -amdgpu-enable-delay-alu=0 < %s | FileCheck %s --check-prefixes=CHECK,GISEL,GISEL-TRUE167; RUN: llc -mtriple=amdgcn -global-isel -mcpu=gfx1100 -mattr=-real-true16 -amdgpu-enable-delay-alu=0 < %s | FileCheck %s --check-prefixes=CHECK,GISEL,GISEL-FAKE168 9declare i64 @llvm.amdgcn.ballot.i64(i1)10declare i64 @llvm.ctpop.i64(i64)11 12; Test ballot(0)13 14define amdgpu_cs i64 @constant_false() {15; CHECK-LABEL: constant_false:16; CHECK: ; %bb.0:17; CHECK-NEXT: s_mov_b32 s0, 018; CHECK-NEXT: s_mov_b32 s1, 019; CHECK-NEXT: ; return to shader part epilog20 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 0)21 ret i64 %ballot22}23 24; Test ballot(1)25 26define amdgpu_cs i64 @constant_true() {27; DAGISEL-LABEL: constant_true:28; DAGISEL: ; %bb.0:29; DAGISEL-NEXT: s_mov_b32 s0, exec_lo30; DAGISEL-NEXT: s_mov_b32 s1, exec_hi31; DAGISEL-NEXT: ; return to shader part epilog32;33; GISEL-LABEL: constant_true:34; GISEL: ; %bb.0:35; GISEL-NEXT: s_mov_b32 s0, exec_lo36; GISEL-NEXT: s_mov_b32 s1, 037; GISEL-NEXT: ; return to shader part epilog38 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 1)39 ret i64 %ballot40}41 42; Test ballot of a non-comparison operation43 44define amdgpu_cs i64 @non_compare(i32 %x) {45; DAGISEL-LABEL: non_compare:46; DAGISEL: ; %bb.0:47; DAGISEL-NEXT: v_and_b32_e32 v0, 1, v048; DAGISEL-NEXT: s_mov_b32 s1, 049; DAGISEL-NEXT: v_cmp_ne_u32_e64 s0, 0, v050; DAGISEL-NEXT: ; return to shader part epilog51;52; GISEL-TRUE16-LABEL: non_compare:53; GISEL-TRUE16: ; %bb.0:54; GISEL-TRUE16-NEXT: v_and_b16 v0.l, 1, v0.l55; GISEL-TRUE16-NEXT: s_mov_b32 s1, 056; GISEL-TRUE16-NEXT: v_cmp_ne_u16_e32 vcc_lo, 0, v0.l57; GISEL-TRUE16-NEXT: s_and_b32 s0, vcc_lo, exec_lo58; GISEL-TRUE16-NEXT: ; return to shader part epilog59;60; GISEL-FAKE16-LABEL: non_compare:61; GISEL-FAKE16: ; %bb.0:62; GISEL-FAKE16-NEXT: v_and_b32_e32 v0, 1, v063; GISEL-FAKE16-NEXT: s_mov_b32 s1, 064; GISEL-FAKE16-NEXT: v_cmp_ne_u32_e32 vcc_lo, 0, v065; GISEL-FAKE16-NEXT: s_and_b32 s0, vcc_lo, exec_lo66; GISEL-FAKE16-NEXT: ; return to shader part epilog67 %trunc = trunc i32 %x to i168 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %trunc)69 ret i64 %ballot70}71 72; Test ballot of comparisons73 74define amdgpu_cs i64 @compare_ints(i32 %x, i32 %y) {75; CHECK-LABEL: compare_ints:76; CHECK: ; %bb.0:77; CHECK-NEXT: v_cmp_eq_u32_e64 s0, v0, v178; CHECK-NEXT: s_mov_b32 s1, 079; CHECK-NEXT: ; return to shader part epilog80 %cmp = icmp eq i32 %x, %y81 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)82 ret i64 %ballot83}84 85define amdgpu_cs i64 @compare_int_with_constant(i32 %x) {86; DAGISEL-LABEL: compare_int_with_constant:87; DAGISEL: ; %bb.0:88; DAGISEL-NEXT: v_cmp_lt_i32_e64 s0, 0x62, v089; DAGISEL-NEXT: s_mov_b32 s1, 090; DAGISEL-NEXT: ; return to shader part epilog91;92; GISEL-LABEL: compare_int_with_constant:93; GISEL: ; %bb.0:94; GISEL-NEXT: v_cmp_le_i32_e64 s0, 0x63, v095; GISEL-NEXT: s_mov_b32 s1, 096; GISEL-NEXT: ; return to shader part epilog97 %cmp = icmp sge i32 %x, 9998 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)99 ret i64 %ballot100}101 102define amdgpu_cs i64 @compare_floats(float %x, float %y) {103; CHECK-LABEL: compare_floats:104; CHECK: ; %bb.0:105; CHECK-NEXT: v_cmp_gt_f32_e64 s0, v0, v1106; CHECK-NEXT: s_mov_b32 s1, 0107; CHECK-NEXT: ; return to shader part epilog108 %cmp = fcmp ogt float %x, %y109 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)110 ret i64 %ballot111}112 113define amdgpu_cs i64 @ctpop_of_ballot(float %x, float %y) {114; CHECK-LABEL: ctpop_of_ballot:115; CHECK: ; %bb.0:116; CHECK-NEXT: v_cmp_gt_f32_e64 s0, v0, v1117; CHECK-NEXT: s_mov_b32 s1, 0118; CHECK-NEXT: s_bcnt1_i32_b64 s0, s[0:1]119; CHECK-NEXT: ; return to shader part epilog120 %cmp = fcmp ogt float %x, %y121 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %cmp)122 %bcnt = call i64 @llvm.ctpop.i64(i64 %ballot)123 ret i64 %bcnt124}125 126define amdgpu_cs i32 @branch_divergent_ballot64_ne_zero_compare(i32 %v) {127; CHECK-LABEL: branch_divergent_ballot64_ne_zero_compare:128; CHECK: ; %bb.0:129; CHECK-NEXT: v_cmp_gt_u32_e64 s0, 12, v0130; CHECK-NEXT: s_mov_b32 s1, 0131; CHECK-NEXT: s_cmp_eq_u64 s[0:1], 0132; CHECK-NEXT: s_cbranch_scc1 .LBB7_2133; CHECK-NEXT: ; %bb.1: ; %true134; CHECK-NEXT: s_mov_b32 s0, 42135; CHECK-NEXT: s_branch .LBB7_3136; CHECK-NEXT: .LBB7_2: ; %false137; CHECK-NEXT: s_mov_b32 s0, 33138; CHECK-NEXT: s_branch .LBB7_3139; CHECK-NEXT: .LBB7_3:140 %c = icmp ult i32 %v, 12141 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %c)142 %ballot_ne_zero = icmp ne i64 %ballot, 0143 br i1 %ballot_ne_zero, label %true, label %false144true:145 ret i32 42146false:147 ret i32 33148}149 150define amdgpu_cs i32 @branch_divergent_ballot64_ne_zero_and(i32 %v1, i32 %v2) {151; DAGISEL-LABEL: branch_divergent_ballot64_ne_zero_and:152; DAGISEL: ; %bb.0:153; DAGISEL-NEXT: v_cmp_gt_u32_e32 vcc_lo, 12, v0154; DAGISEL-NEXT: v_cmp_lt_u32_e64 s0, 34, v1155; DAGISEL-NEXT: s_mov_b32 s1, 0156; DAGISEL-NEXT: s_and_b32 s0, vcc_lo, s0157; DAGISEL-NEXT: v_cndmask_b32_e64 v0, 0, 1, s0158; DAGISEL-NEXT: v_cmp_ne_u32_e64 s0, 0, v0159; DAGISEL-NEXT: s_cmp_eq_u64 s[0:1], 0160; DAGISEL-NEXT: s_cbranch_scc1 .LBB8_2161; DAGISEL-NEXT: ; %bb.1: ; %true162; DAGISEL-NEXT: s_mov_b32 s0, 42163; DAGISEL-NEXT: s_branch .LBB8_3164; DAGISEL-NEXT: .LBB8_2: ; %false165; DAGISEL-NEXT: s_mov_b32 s0, 33166; DAGISEL-NEXT: s_branch .LBB8_3167; DAGISEL-NEXT: .LBB8_3:168;169; GISEL-LABEL: branch_divergent_ballot64_ne_zero_and:170; GISEL: ; %bb.0:171; GISEL-NEXT: v_cmp_gt_u32_e32 vcc_lo, 12, v0172; GISEL-NEXT: v_cmp_lt_u32_e64 s0, 34, v1173; GISEL-NEXT: s_mov_b32 s1, 0174; GISEL-NEXT: s_and_b32 s0, vcc_lo, s0175; GISEL-NEXT: s_cmp_eq_u64 s[0:1], 0176; GISEL-NEXT: s_cbranch_scc1 .LBB8_2177; GISEL-NEXT: ; %bb.1: ; %true178; GISEL-NEXT: s_mov_b32 s0, 42179; GISEL-NEXT: s_branch .LBB8_3180; GISEL-NEXT: .LBB8_2: ; %false181; GISEL-NEXT: s_mov_b32 s0, 33182; GISEL-NEXT: s_branch .LBB8_3183; GISEL-NEXT: .LBB8_3:184 %v1c = icmp ult i32 %v1, 12185 %v2c = icmp ugt i32 %v2, 34186 %c = and i1 %v1c, %v2c187 %ballot = call i64 @llvm.amdgcn.ballot.i64(i1 %c)188 %ballot_ne_zero = icmp ne i64 %ballot, 0189 br i1 %ballot_ne_zero, label %true, label %false190true:191 ret i32 42192false:193 ret i32 33194}195;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:196; DAGISEL-FAKE16: {{.*}}197; DAGISEL-TRUE16: {{.*}}198