1; RUN: opt < %s -jump-threading -S -verify | FileCheck %s
2
3target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
4target triple = "nvptx64-nvidia-cuda"
5
6$wrapped_tid = comdat any
7
8$foo = comdat any
9
10define i32 @wrapped_tid() #0 comdat align 32 {
11  %1 = call i32 @tid()
12  ret i32 %1
13}
14
15declare void @llvm.nvvm.barrier0() #1
16
17; We had a bug where we duplicated basic blocks containing convergent
18; functions like @llvm.nvvm.barrier0 below.  Verify that we don't do
19; that.
20define void @foo() local_unnamed_addr #2 comdat align 32 {
21; CHECK-LABEL: @foo
22  %1 = call i32 @tid()
23  %2 = urem i32 %1, 7
24  br label %3
25
263:
27  %4 = icmp eq i32 %1, 0
28  br i1 %4, label %5, label %6
29
305:
31  call void @bar()
32  br label %6
33
346:
35; CHECK: call void @llvm.nvvm.barrier0()
36; CHECK-NOT: call void @llvm.nvvm.barrier0()
37  call void @llvm.nvvm.barrier0()
38  %7 = icmp eq i32 %2, 0
39  br i1 %7, label %11, label %8
40
418:
42  %9 = icmp ult i32 %1, 49
43  br i1 %9, label %10, label %11
44
4510:
46  call void @llvm.trap()
47  unreachable
48
4911:
50  br label %3
51}
52
53declare i32 @tid() #2
54
55declare void @bar()
56
57declare void @llvm.trap() #3
58
59attributes #1 = { convergent }
60attributes #2 = { readnone }
61attributes #3 = { noreturn }
62attributes #4 = { convergent }
63