1 ; RUN: opt -passes=gvn -S -o - %s | FileCheck %s
3 %struct.sk_buff = type opaque
5 @l2tp_recv_dequeue_session = external dso_local local_unnamed_addr global i32, align 4
6 @l2tp_recv_dequeue_skb = external dso_local local_unnamed_addr global ptr, align 8
7 @l2tp_recv_dequeue_session_2 = external dso_local local_unnamed_addr global i32, align 4
8 @l2tp_recv_dequeue_session_0 = external dso_local local_unnamed_addr global i32, align 4
10 declare void @llvm.assume(i1 noundef)
12 define dso_local void @l2tp_recv_dequeue() local_unnamed_addr {
14 %0 = load i32, ptr @l2tp_recv_dequeue_session, align 4
15 %conv = sext i32 %0 to i64
16 %1 = inttoptr i64 %conv to ptr
17 %2 = load i32, ptr @l2tp_recv_dequeue_session_2, align 4
18 %tobool.not = icmp eq i32 %2, 0
21 for.cond: ; preds = %if.end, %entry
22 %storemerge = phi ptr [ %1, %entry ], [ null, %if.end ]
23 store ptr %storemerge, ptr @l2tp_recv_dequeue_skb, align 8
24 br i1 %tobool.not, label %if.end, label %if.then
26 if.then: ; preds = %for.cond
27 %3 = load i32, ptr %storemerge, align 4
28 store i32 %3, ptr @l2tp_recv_dequeue_session_0, align 4
29 ; Splitting the critical edge from if.then to if.end will fail, but should not
30 ; cause an infinite loop in GVN. If we can one day split edges of callbr
31 ; indirect targets, great!
32 ; CHECK: callbr void asm sideeffect "", "!i,~{dirflag},~{fpsr},~{flags}"()
33 ; CHECK-NEXT: to label %asm.fallthrough.i [label %if.end]
34 callbr void asm sideeffect "", "!i,~{dirflag},~{fpsr},~{flags}"()
35 to label %asm.fallthrough.i [label %if.end]
37 asm.fallthrough.i: ; preds = %if.then
40 if.end: ; preds = %asm.fallthrough.i, %if.then, %for.cond
41 %4 = load i32, ptr %storemerge, align 4
42 %tobool2.not = icmp eq i32 %4, 0
43 tail call void @llvm.assume(i1 %tobool2.not)