1; RUN: opt -mtriple amdgcn-unknown-amdhsa -analyze -divergence -use-gpu-divergence-analysis %s | FileCheck %s 2 3define amdgpu_kernel void @hidden_diverge(i32 %n, i32 %a, i32 %b) #0 { 4; CHECK-LABEL: Printing analysis 'Legacy Divergence Analysis' for function 'hidden_diverge' 5entry: 6 %tid = call i32 @llvm.amdgcn.workitem.id.x() 7 %cond.var = icmp slt i32 %tid, 0 8 br i1 %cond.var, label %B, label %C ; divergent 9; CHECK: DIVERGENT: br i1 %cond.var, 10B: 11 %cond.uni = icmp slt i32 %n, 0 12 br i1 %cond.uni, label %C, label %merge ; uniform 13; CHECK-NOT: DIVERGENT: br i1 %cond.uni, 14C: 15 %phi.var.hidden = phi i32 [ 1, %entry ], [ 2, %B ] 16; CHECK: DIVERGENT: %phi.var.hidden = phi i32 17 br label %merge 18merge: 19 %phi.ipd = phi i32 [ %a, %B ], [ %b, %C ] 20; CHECK: DIVERGENT: %phi.ipd = phi i32 21 ret void 22} 23 24define amdgpu_kernel void @hidden_loop_ipd(i32 %n, i32 %a, i32 %b) #0 { 25; CHECK-LABEL: Printing analysis 'Legacy Divergence Analysis' for function 'hidden_loop_ipd' 26entry: 27 %tid = call i32 @llvm.amdgcn.workitem.id.x() 28 %cond.var = icmp slt i32 %tid, 0 29; CHECK: DIVERGENT: %cond.var = icmp 30 %cond.uni = icmp slt i32 %n, 0 31; CHECK-NOT: DIVERGENT: %cond.uni = icmp 32 br label %for.header 33for.header: 34 br i1 %cond.var, label %A, label %B 35A: 36 br label %C 37B: 38 br label %C 39C: 40 br i1 %cond.uni, label %E, label %D 41D: 42 br i1 %cond.var, label %for.header, label %F 43 44E: 45 %e.lcssa.uni = phi i32 [ 0, %C ] 46; CHECK-NOT: DIVERGENT: %e.lcssa.uni = phi i32 47 br label %G 48 49F: 50 %f.lcssa.uni = phi i32 [ 1, %D ] 51; CHECK-NOT: DIVERGENT: %f.lcssa.uni = phi i32 52 br label %G 53 54G: 55 %g.join.var = phi i32 [ %e.lcssa.uni, %E ], [ %f.lcssa.uni, %F ] 56; CHECK: DIVERGENT: %g.join.var = phi i32 57 ret void 58} 59 60 61declare i32 @llvm.amdgcn.workitem.id.x() #0 62 63attributes #0 = { nounwind readnone } 64