1; RUN: opt -passes=gvn -S < %s | FileCheck %s
2
3; CHECK: define {{.*}}@eggs
4
5%struct.zot = type { i32 (...)** }
6%struct.wombat = type { i8* }
7%struct.baz = type { i8, i8* }
8
9@global = hidden unnamed_addr constant i8* bitcast (void (%struct.zot*, i1)* @quux to i8*)
10
11declare i8* @f()
12
13define hidden void @eggs(%struct.zot* %arg, i1 %arg2, i32* %arg3, i32 %arg4, %struct.baz** %arg5) unnamed_addr align 2 {
14bb:
15  %tmp = alloca %struct.wombat, align 8
16  %tmp1 = getelementptr %struct.zot, %struct.zot* %arg, i64 0, i32 0
17  store i32 (...)** bitcast (i8** @global to i32 (...)**), i32 (...)*** %tmp1, align 8, !invariant.group !0
18  br i1 %arg2, label %bb4, label %bb2
19
20bb2:                                              ; preds = %bb
21  %tmp3 = atomicrmw sub i32* %arg3, i32 %arg4 acq_rel, align 4
22  br label %bb4
23
24bb4:                                              ; preds = %bb2, %bb
25  %tmp5 = load %struct.baz*, %struct.baz** %arg5, align 8
26  %tmp6 = getelementptr inbounds %struct.baz, %struct.baz* %tmp5, i64 0, i32 1
27  br i1 %arg2, label %bb9, label %bb7
28
29bb7:                                              ; preds = %bb4
30  %tmp8 = tail call i8* @f()
31  br label %bb9
32
33bb9:                                              ; preds = %bb7, %bb4
34  %tmp10 = load %struct.baz*, %struct.baz** %arg5, align 8
35  %tmp11 = getelementptr inbounds %struct.baz, %struct.baz* %tmp10, i64 0, i32 0
36  %tmp12 = bitcast %struct.zot* %arg to void (%struct.zot*, i1)***
37  %tmp13 = load void (%struct.zot*, i1)**, void (%struct.zot*, i1)*** %tmp12, align 8, !invariant.group !0
38  %tmp14 = getelementptr inbounds void (%struct.zot*, i1)*, void (%struct.zot*, i1)** %tmp13, i64 0
39  %tmp15 = load void (%struct.zot*, i1)*, void (%struct.zot*, i1)** %tmp14, align 8
40  tail call void %tmp15(%struct.zot* %arg, i1 %arg2)
41  %tmp16 = getelementptr inbounds %struct.wombat, %struct.wombat* %tmp, i64 0, i32 0
42  %tmp17 = load i8*, i8** %tmp16, align 8
43  %tmp18 = icmp eq i8* %tmp17, null
44  ret void
45}
46
47; Function Attrs: nounwind willreturn
48declare hidden void @quux(%struct.zot*, i1) unnamed_addr #0 align 2
49
50attributes #0 = { nounwind willreturn }
51
52!0 = !{}
53