1 ; RUN: opt -instcombine -S < %s | FileCheck -enable-var-scope %s
3 declare i32 @k() convergent
6 declare i64 @llvm.read_register.i64(metadata) nounwind
9 ; Convergent attr shouldn't be removed here; k is convergent.
10 ; CHECK: call i32 @k() [[$CONVERGENT_ATTR:#[0-9]+]]
11 %a = call i32 @k() convergent
15 define i32 @extern_no_attr() {
16 ; Convergent attr shouldn't be added here, even though k is convergent.
17 ; CHECK: call i32 @k(){{$}}
22 define i32 @no_extern() {
23 ; Convergent should be removed here, as the target is convergent.
24 ; CHECK: call i32 @f(){{$}}
25 %a = call i32 @f() convergent
29 define i32 @indirect_call(i32 ()* %f) {
30 ; CHECK: call i32 %f() [[$CONVERGENT_ATTR]]
31 %a = call i32 %f() convergent
35 ; do not remove from convergent intrinsic call sites
36 ; CHECK-LABEL: @convergent_intrinsic_call(
37 ; CHECK: call i64 @llvm.read_register.i64(metadata !0) [[$CONVERGENT_ATTR]]
38 define i64 @convergent_intrinsic_call() {
39 %val = call i64 @llvm.read_register.i64(metadata !0) convergent
43 ; CHECK: [[$CONVERGENT_ATTR]] = { convergent }