Kazu Hirata | 4698bf1 | 2020-02-05 08:24:01 -0800 | [diff] [blame] | 1 | ; RUN: opt < %s -jump-threading -S -verify | FileCheck %s |
| 2 | |
| 3 | target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64" |
| 4 | target triple = "nvptx64-nvidia-cuda" |
| 5 | |
| 6 | $wrapped_tid = comdat any |
| 7 | |
| 8 | $foo = comdat any |
| 9 | |
| 10 | define i32 @wrapped_tid() #0 comdat align 32 { |
| 11 | %1 = call i32 @tid() |
| 12 | ret i32 %1 |
| 13 | } |
| 14 | |
| 15 | declare 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. |
| 20 | define 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 | |
| 26 | 3: |
| 27 | %4 = icmp eq i32 %1, 0 |
| 28 | br i1 %4, label %5, label %6 |
| 29 | |
| 30 | 5: |
| 31 | call void @bar() |
| 32 | br label %6 |
| 33 | |
| 34 | 6: |
| 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 | |
| 41 | 8: |
| 42 | %9 = icmp ult i32 %1, 49 |
| 43 | br i1 %9, label %10, label %11 |
| 44 | |
| 45 | 10: |
| 46 | call void @llvm.trap() |
| 47 | unreachable |
| 48 | |
| 49 | 11: |
| 50 | br label %3 |
| 51 | } |
| 52 | |
| 53 | declare i32 @tid() #2 |
| 54 | |
| 55 | declare void @bar() |
| 56 | |
| 57 | declare void @llvm.trap() #3 |
| 58 | |
| 59 | attributes #1 = { convergent } |
| 60 | attributes #2 = { readnone } |
| 61 | attributes #3 = { noreturn } |
| 62 | attributes #4 = { convergent } |