1*ae77acebSpvanhout; RUN: opt -mtriple amdgcn-unknown-amdhsa -passes='print<uniformity>' -disable-output %s 2>&1 | FileCheck %s 2*ae77acebSpvanhout 3*ae77acebSpvanhoutdeclare i32 @gf2(i32) 4*ae77acebSpvanhoutdeclare i32 @gf1(i32) 5*ae77acebSpvanhout 6*ae77acebSpvanhoutdefine void @tw1(ptr addrspace(4) noalias nocapture readonly %A, ptr addrspace(4) noalias nocapture %B) local_unnamed_addr #2 { 7*ae77acebSpvanhout; CHECK: for function 'tw1': 8*ae77acebSpvanhout; CHECK-DAG: DIVERGENT: ptr addrspace(4) %A 9*ae77acebSpvanhout; CHECK-DAG: DIVERGENT: ptr addrspace(4) %B 10*ae77acebSpvanhoutentry: 11*ae77acebSpvanhout; CHECK: DIVERGENT: %call = tail call i32 @gf2(i32 0) #0 12*ae77acebSpvanhout; CHECK: DIVERGENT: %cmp = icmp ult i32 %call, 16 13*ae77acebSpvanhout; CHECK: DIVERGENT: br i1 %cmp, label %if.then, label %new_exit 14*ae77acebSpvanhout %call = tail call i32 @gf2(i32 0) #3 15*ae77acebSpvanhout %cmp = icmp ult i32 %call, 16 16*ae77acebSpvanhout br i1 %cmp, label %if.then, label %new_exit 17*ae77acebSpvanhout 18*ae77acebSpvanhoutif.then: 19*ae77acebSpvanhout; CHECK: DIVERGENT: %call1 = tail call i32 @gf1(i32 0) #0 20*ae77acebSpvanhout; CHECK: DIVERGENT: %arrayidx = getelementptr inbounds i32, ptr addrspace(4) %A, i32 %call1 21*ae77acebSpvanhout; CHECK: DIVERGENT: %0 = load i32, ptr addrspace(4) %arrayidx, align 4 22*ae77acebSpvanhout; CHECK: DIVERGENT: %cmp225 = icmp sgt i32 %0, 0 23*ae77acebSpvanhout; CHECK: DIVERGENT: %arrayidx10 = getelementptr inbounds i32, ptr addrspace(4) %B, i32 %call1 24*ae77acebSpvanhout; CHECK: DIVERGENT: br i1 %cmp225, label %while.body.preheader, label %if.then.while.end_crit_edge 25*ae77acebSpvanhout %call1 = tail call i32 @gf1(i32 0) #4 26*ae77acebSpvanhout %arrayidx = getelementptr inbounds i32, ptr addrspace(4) %A, i32 %call1 27*ae77acebSpvanhout %0 = load i32, ptr addrspace(4) %arrayidx, align 4 28*ae77acebSpvanhout %cmp225 = icmp sgt i32 %0, 0 29*ae77acebSpvanhout %arrayidx10 = getelementptr inbounds i32, ptr addrspace(4) %B, i32 %call1 30*ae77acebSpvanhout br i1 %cmp225, label %while.body.preheader, label %if.then.while.end_crit_edge 31*ae77acebSpvanhout 32*ae77acebSpvanhoutwhile.body.preheader: 33*ae77acebSpvanhout br label %while.body 34*ae77acebSpvanhout 35*ae77acebSpvanhoutif.then.while.end_crit_edge: 36*ae77acebSpvanhout; CHECK: DIVERGENT: %.pre = load i32, ptr addrspace(4) %arrayidx10, align 4 37*ae77acebSpvanhout %.pre = load i32, ptr addrspace(4) %arrayidx10, align 4 38*ae77acebSpvanhout br label %while.end 39*ae77acebSpvanhout 40*ae77acebSpvanhoutwhile.body: 41*ae77acebSpvanhout; CHECK-NOT: DIVERGENT: %i.026 = phi i32 [ %inc, %if.end.while.body_crit_edge ], [ 0, %while.body.preheader ] 42*ae77acebSpvanhout; CHECK: DIVERGENT: %call3 = tail call i32 @gf1(i32 0) #0 43*ae77acebSpvanhout; CHECK: DIVERGENT: %cmp4 = icmp ult i32 %call3, 10 44*ae77acebSpvanhout; CHECK: DIVERGENT: %arrayidx6 = getelementptr inbounds i32, ptr addrspace(4) %A, i32 %i.026 45*ae77acebSpvanhout; CHECK: DIVERGENT: %1 = load i32, ptr addrspace(4) %arrayidx6, align 4 46*ae77acebSpvanhout; CHECK: DIVERGENT: br i1 %cmp4, label %if.then5, label %if.else 47*ae77acebSpvanhout %i.026 = phi i32 [ %inc, %if.end.while.body_crit_edge ], [ 0, %while.body.preheader ] 48*ae77acebSpvanhout %call3 = tail call i32 @gf1(i32 0) #4 49*ae77acebSpvanhout %cmp4 = icmp ult i32 %call3, 10 50*ae77acebSpvanhout %arrayidx6 = getelementptr inbounds i32, ptr addrspace(4) %A, i32 %i.026 51*ae77acebSpvanhout %1 = load i32, ptr addrspace(4) %arrayidx6, align 4 52*ae77acebSpvanhout br i1 %cmp4, label %if.then5, label %if.else 53*ae77acebSpvanhout 54*ae77acebSpvanhoutif.then5: 55*ae77acebSpvanhout; CHECK: DIVERGENT: %mul = shl i32 %1, 1 56*ae77acebSpvanhout; CHECK: DIVERGENT: %2 = load i32, ptr addrspace(4) %arrayidx10, align 4 57*ae77acebSpvanhout; CHECK: DIVERGENT: %add = add nsw i32 %2, %mul 58*ae77acebSpvanhout %mul = shl i32 %1, 1 59*ae77acebSpvanhout %2 = load i32, ptr addrspace(4) %arrayidx10, align 4 60*ae77acebSpvanhout %add = add nsw i32 %2, %mul 61*ae77acebSpvanhout br label %if.end 62*ae77acebSpvanhout 63*ae77acebSpvanhoutif.else: 64*ae77acebSpvanhout; CHECK: DIVERGENT: %mul9 = shl i32 %1, 2 65*ae77acebSpvanhout; CHECK: DIVERGENT: %3 = load i32, ptr addrspace(4) %arrayidx10, align 4 66*ae77acebSpvanhout; CHECK: DIVERGENT: %add11 = add nsw i32 %3, %mul9 67*ae77acebSpvanhout %mul9 = shl i32 %1, 2 68*ae77acebSpvanhout %3 = load i32, ptr addrspace(4) %arrayidx10, align 4 69*ae77acebSpvanhout %add11 = add nsw i32 %3, %mul9 70*ae77acebSpvanhout br label %if.end 71*ae77acebSpvanhout 72*ae77acebSpvanhoutif.end: 73*ae77acebSpvanhout; CHECK: DIVERGENT: %storemerge = phi i32 [ %add11, %if.else ], [ %add, %if.then5 ] 74*ae77acebSpvanhout; CHECK: DIVERGENT: store i32 %storemerge, ptr addrspace(4) %arrayidx10, align 4 75*ae77acebSpvanhout; CHECK-NOT: DIVERGENT: %inc = add nuw nsw i32 %i.026, 1 76*ae77acebSpvanhout; CHECK: DIVERGENT: %exitcond = icmp ne i32 %inc, %0 77*ae77acebSpvanhout; CHECK: DIVERGENT: br i1 %exitcond, label %if.end.while.body_crit_edge, label %while.end.loopexit 78*ae77acebSpvanhout %storemerge = phi i32 [ %add11, %if.else ], [ %add, %if.then5 ] 79*ae77acebSpvanhout store i32 %storemerge, ptr addrspace(4) %arrayidx10, align 4 80*ae77acebSpvanhout %inc = add nuw nsw i32 %i.026, 1 81*ae77acebSpvanhout %exitcond = icmp ne i32 %inc, %0 82*ae77acebSpvanhout br i1 %exitcond, label %if.end.while.body_crit_edge, label %while.end.loopexit 83*ae77acebSpvanhout 84*ae77acebSpvanhoutif.end.while.body_crit_edge: 85*ae77acebSpvanhout br label %while.body 86*ae77acebSpvanhout 87*ae77acebSpvanhoutwhile.end.loopexit: 88*ae77acebSpvanhout; CHECK: DIVERGENT: %storemerge.lcssa = phi i32 [ %storemerge, %if.end ] 89*ae77acebSpvanhout %storemerge.lcssa = phi i32 [ %storemerge, %if.end ] 90*ae77acebSpvanhout br label %while.end 91*ae77acebSpvanhout 92*ae77acebSpvanhoutwhile.end: 93*ae77acebSpvanhout; CHECK: DIVERGENT: %4 = phi i32 [ %.pre, %if.then.while.end_crit_edge ], [ %storemerge.lcssa, %while.end.loopexit ] 94*ae77acebSpvanhout; CHECK: DIVERGENT: %i.0.lcssa = phi i32 [ 0, %if.then.while.end_crit_edge ], [ %0, %while.end.loopexit ] 95*ae77acebSpvanhout; CHECK: DIVERGENT: %sub = sub nsw i32 %4, %i.0.lcssa 96*ae77acebSpvanhout; CHECK: DIVERGENT: store i32 %sub, ptr addrspace(4) %arrayidx10, align 4 97*ae77acebSpvanhout %4 = phi i32 [ %.pre, %if.then.while.end_crit_edge ], [ %storemerge.lcssa, %while.end.loopexit ] 98*ae77acebSpvanhout %i.0.lcssa = phi i32 [ 0, %if.then.while.end_crit_edge ], [ %0, %while.end.loopexit ] 99*ae77acebSpvanhout %sub = sub nsw i32 %4, %i.0.lcssa 100*ae77acebSpvanhout store i32 %sub, ptr addrspace(4) %arrayidx10, align 4 101*ae77acebSpvanhout br label %new_exit 102*ae77acebSpvanhout 103*ae77acebSpvanhoutnew_exit: 104*ae77acebSpvanhout ret void 105*ae77acebSpvanhout} 106*ae77acebSpvanhout 107*ae77acebSpvanhoutattributes #0 = { nounwind readnone } 108*ae77acebSpvanhoutattributes #1 = { nounwind readnone } 109*ae77acebSpvanhoutattributes #2 = { nounwind readnone } 110*ae77acebSpvanhoutattributes #3 = { nounwind readnone } 111*ae77acebSpvanhoutattributes #4 = { nounwind readnone } 112