1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt -S -passes=gvn < %s | FileCheck %s
4 declare void @willreturn() nounwind willreturn
6 declare void @capture(ptr)
8 ; Make sure ICF is invalidated when the callee becomes known.
10 define i64 @test(ptr %p) {
11 ; CHECK-LABEL: define i64 @test(
12 ; CHECK-SAME: ptr [[P:%.*]]) {
14 ; CHECK-NEXT: [[A:%.*]] = alloca [2 x ptr], align 8
15 ; CHECK-NEXT: [[A2:%.*]] = getelementptr ptr, ptr [[A]], i64 1
16 ; CHECK-NEXT: call void @capture(ptr [[A]])
17 ; CHECK-NEXT: br i1 false, label [[IF:%.*]], label [[ENTRY_EXIT_CRIT_EDGE:%.*]]
18 ; CHECK: entry.exit_crit_edge:
19 ; CHECK-NEXT: [[RES_PRE:%.*]] = load i64, ptr [[A2]], align 8
20 ; CHECK-NEXT: br label [[EXIT:%.*]]
22 ; CHECK-NEXT: [[P1:%.*]] = load ptr, ptr [[A2]], align 8
23 ; CHECK-NEXT: br label [[EXIT]]
25 ; CHECK-NEXT: [[RES:%.*]] = phi i64 [ [[RES_PRE]], [[ENTRY_EXIT_CRIT_EDGE]] ], [ poison, [[IF]] ]
26 ; CHECK-NEXT: store ptr @willreturn, ptr [[P]], align 8
27 ; CHECK-NEXT: tail call void @willreturn()
28 ; CHECK-NEXT: ret i64 [[RES]]
31 %a = alloca [2 x ptr], align 8
32 %a2 = getelementptr ptr, ptr %a, i64 1
33 call void @capture(ptr %a)
34 br i1 false, label %if, label %exit
37 %p0 = load ptr, ptr %a, align 8
38 %p1 = load ptr, ptr %a2, align 8
42 store ptr @willreturn, ptr %p
43 %p2 = load ptr, ptr %a, align 8
44 %pgocount.i = load i64, ptr %p2, align 8
45 %fn = load ptr, ptr %p
47 %res = load i64, ptr %a2, align 8