1 ; RUN: opt -mtriple amdgcn-unknown-amdhsa -analyze -divergence -use-gpu-divergence-analysis %s | FileCheck %s
3 define amdgpu_kernel void @hidden_diverge(i32 %n, i32 %a, i32 %b) #0 {
4 ; CHECK-LABEL: Printing analysis 'Legacy Divergence Analysis' for function 'hidden_diverge'
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,
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,
15 %phi.var.hidden = phi i32 [ 1, %entry ], [ 2, %B ]
16 ; CHECK: DIVERGENT: %phi.var.hidden = phi i32
19 %phi.ipd = phi i32 [ %a, %B ], [ %b, %C ]
20 ; CHECK: DIVERGENT: %phi.ipd = phi i32
24 define 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'
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
34 br i1 %cond.var, label %A, label %B
40 br i1 %cond.uni, label %E, label %D
42 br i1 %cond.var, label %for.header, label %F
45 %e.lcssa.uni = phi i32 [ 0, %C ]
46 ; CHECK-NOT: DIVERGENT: %e.lcssa.uni = phi i32
50 %f.lcssa.uni = phi i32 [ 1, %D ]
51 ; CHECK-NOT: DIVERGENT: %f.lcssa.uni = phi i32
55 %g.join.var = phi i32 [ %e.lcssa.uni, %E ], [ %f.lcssa.uni, %F ]
56 ; CHECK: DIVERGENT: %g.join.var = phi i32
61 declare i32 @llvm.amdgcn.workitem.id.x() #0
63 attributes #0 = { nounwind readnone }