Index: lib/Transforms/Utils/SimplifyCFG.cpp =================================================================== --- lib/Transforms/Utils/SimplifyCFG.cpp +++ lib/Transforms/Utils/SimplifyCFG.cpp @@ -1442,7 +1442,7 @@ // and merging inline-asm instructions can potentially create arguments // that cannot satisfy the inline-asm constraints. if (const auto *C = dyn_cast(I)) - if (C->isInlineAsm()) + if (C->isInlineAsm() || C->isConvergent()) return false; // Everything must have only one use too, apart from stores which Index: test/Transforms/SimplifyCFG/sink-common-code.ll =================================================================== --- test/Transforms/SimplifyCFG/sink-common-code.ll +++ test/Transforms/SimplifyCFG/sink-common-code.ll @@ -818,6 +818,31 @@ ; CHECK: right: ; CHECK-NEXT: %val1 = call i32 @call_target() [ "deopt"(i32 20) ] +declare i32 @convergent_call(i32) + +define i32 @test_no_sink_convergent(i1 %cond) { +entry: + br i1 %cond, label %if.then, label %if.else + +if.then: + %tmp0 = call i32 @convergent_call(i32 0) #0 + br label %if.end + +if.else: + %tmp1 = call i32 @convergent_call(i32 1) #0 + br label %if.end + +if.end: + %tmp2 = phi i32 [%tmp0, %if.then], [%tmp1, %if.else] + ret i32 %tmp2 +} + +; CHECK-LABEL: @convergent_call +; CHECK: @convergent_call(i32 0) +; CHECK: @convergent_call(i32 1) + +attributes #0 = { convergent } + ; CHECK: ![[TBAA]] = !{![[TYPE:[0-9]]], ![[TYPE]], i64 0} ; CHECK: ![[TYPE]] = !{!"float", ![[TEXT:[0-9]]]} ; CHECK: ![[TEXT]] = !{!"an example type tree"}