1 ; RUN: opt -passes='require<profile-summary>,function(codegenprepare)' -S -mtriple=x86_64-linux < %s | FileCheck %s
3 ; The ret instruction can be duplicated into BB case2 even though there is an
4 ; intermediate BB exit1 and call to llvm.assume.
6 @ptr = external global ptr, align 8
8 ; CHECK: %ret1 = tail call ptr @qux()
9 ; CHECK-NEXT: ret ptr %ret1
11 ; CHECK: %ret2 = tail call ptr @bar()
12 ; CHECK-NEXT: ret ptr %ret2
14 define ptr @foo(i64 %size, i64 %v1, i64 %v2) {
17 call void @llvm.lifetime.start.p0(i64 -1, ptr %a) nounwind
18 %cmp1 = icmp ult i64 %size, 1025
19 br i1 %cmp1, label %if.end, label %case1
22 %ret1 = tail call ptr @qux()
26 %cmp2 = icmp ult i64 %v1, %v2
27 br i1 %cmp2, label %case3, label %case2
30 %ret2 = tail call ptr @bar()
34 %ret3 = load ptr, ptr @ptr, align 8
38 %retval1 = phi ptr [ %ret2, %case2 ], [ %ret3, %case3 ]
39 %cmp3 = icmp ne ptr %retval1, null
40 tail call void @llvm.assume(i1 %cmp3)
44 %retval2 = phi ptr [ %ret1, %case1 ], [ %retval1, %exit1 ]
45 call void @llvm.lifetime.end.p0(i64 -1, ptr %a) nounwind
49 declare void @llvm.assume(i1)
52 declare void @llvm.lifetime.start.p0(i64, ptr nocapture) nounwind
53 declare void @llvm.lifetime.end.p0(i64, ptr nocapture) nounwind