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