1 ; RUN: opt -passes=instcombine -available-load-scan-limit=2 -S < %s | FileCheck %s
3 %struct.nonbonded = type { [2 x %struct.CompAtom*], [2 x %struct.CompAtomExt*], [2 x %struct.CompAtom*], [2 x %class.Vector*], [2 x %class.Vector*], [2 x i32], %class.Vector, double*, double*, %class.ComputeNonbondedWorkArrays*, %class.Pairlists*, i32, i32, double, double, i32, i32, i32, i32 }
4 %struct.CompAtomExt = type { i32 }
5 %struct.CompAtom = type { %class.Vector, float, i16, i8, i8 }
6 %class.Vector = type { double, double, double }
7 %class.ComputeNonbondedWorkArrays = type { %class.ResizeArray, %class.ResizeArray.0, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray, %class.ResizeArray.2, %class.ResizeArray.2 }
8 %class.ResizeArray.0 = type { i32 (...)**, %class.ResizeArrayRaw.1* }
9 %class.ResizeArrayRaw.1 = type <{ double*, i8*, i32, i32, i32, float, i32, [4 x i8] }>
10 %class.ResizeArray = type { i32 (...)**, %class.ResizeArrayRaw* }
11 %class.ResizeArrayRaw = type <{ i16*, i8*, i32, i32, i32, float, i32, [4 x i8] }>
12 %class.ResizeArray.2 = type { i32 (...)**, %class.ResizeArrayRaw.3* }
13 %class.ResizeArrayRaw.3 = type <{ %class.Vector*, i8*, i32, i32, i32, float, i32, [4 x i8] }>
14 %class.Pairlists = type { i16*, i32, i32 }
16 define dso_local void @merge(%struct.nonbonded* nocapture readonly %params) local_unnamed_addr align 2 {
17 ;; Check the minPart4 and minPart assignments are merged.
18 ; CHECK-LABEL: @merge(
19 ; CHECK-COUNT-1: getelementptr inbounds %struct.nonbonded, %struct.nonbonded* %params, i64 0, i32 16
20 ; CHECK-NOT: getelementptr inbounds %struct.nonbonded, %struct.nonbonded* %params, i64 0, i32 16
22 %savePairlists3 = getelementptr inbounds %struct.nonbonded, %struct.nonbonded* %params, i64 0, i32 11
23 %0 = load i32, i32* %savePairlists3, align 8
24 %usePairlists4 = getelementptr inbounds %struct.nonbonded, %struct.nonbonded* %params, i64 0, i32 12
25 %1 = load i32, i32* %usePairlists4, align 4
26 %tobool54.not = icmp eq i32 %0, 0
27 br i1 %tobool54.not, label %lor.lhs.false55, label %if.end109
29 lor.lhs.false55: ; preds = %entry
30 %tobool56.not = icmp eq i32 %1, 0
31 br i1 %tobool56.not, label %if.end109, label %if.end109.thread
33 if.end109.thread: ; preds = %lor.lhs.false55
34 %minPart4 = getelementptr inbounds %struct.nonbonded, %struct.nonbonded* %params, i64 0, i32 16
35 %2 = load i32, i32* %minPart4, align 4
36 call void @llvm.pseudoprobe(i64 -6172701105289426098, i64 2, i32 0, i64 -1)
39 if.end109: ; preds = %lor.lhs.false55, %entry
40 %minPart = getelementptr inbounds %struct.nonbonded, %struct.nonbonded* %params, i64 0, i32 16
41 %3 = load i32, i32* %minPart, align 4
42 call void @llvm.pseudoprobe(i64 -6172701105289426098, i64 3, i32 0, i64 -1)
43 %tobool116.not = icmp eq i32 %1, 0
44 br i1 %tobool116.not, label %if.then117, label %if.then138
46 if.then117: ; preds = %if.end109
49 if.then138: ; preds = %if.end109.thread, %if.end109
50 %4 = phi i32 [ %2, %if.end109.thread ], [ %3, %if.end109 ]
51 %tobool139.not = icmp eq i32 %4, 0
52 br i1 %tobool139.not, label %if.else147, label %if.then140
54 if.then140: ; preds = %if.then138
57 if.else147: ; preds = %if.then138
61 define i32 @load(i32* nocapture %a, i32* nocapture %b) {
62 ;; Check the last store is deleted.
64 ; CHECK-NEXT: %1 = getelementptr inbounds i32, i32* %a, i64 1
65 ; CHECK-NEXT: %2 = load i32, i32* %1, align 8
66 ; CHECK-NEXT: %3 = getelementptr inbounds i32, i32* %b, i64 1
67 ; CHECK-NEXT: store i32 %2, i32* %3, align 8
68 ; CHECK-NEXT: call void @llvm.pseudoprobe(i64 5116412291814990879, i64 1, i32 0, i64 -1)
69 ; CHECK-NEXT: ret i32 %[[#]]
70 %1 = getelementptr inbounds i32, i32* %a, i32 1
71 %2 = load i32, i32* %1, align 8
72 %3 = getelementptr inbounds i32, i32* %b, i32 1
73 store i32 %2, i32* %3, align 8
74 %4 = getelementptr inbounds i32, i32* %b, i32 1
75 call void @llvm.pseudoprobe(i64 5116412291814990879, i64 1, i32 0, i64 -1)
76 %5 = load i32, i32* %4, align 8
80 define void @dse(i32* %p) {
81 ;; Check the first store is deleted.
83 ; CHECK-NEXT: call void @llvm.pseudoprobe(i64 5116412291814990879, i64 1, i32 0, i64 -1)
84 ; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4
85 ; CHECK-NEXT: ret void
87 call void @llvm.pseudoprobe(i64 5116412291814990879, i64 1, i32 0, i64 -1)
92 ; Function Attrs: inaccessiblememonly nounwind willreturn
93 declare void @llvm.pseudoprobe(i64, i64, i32, i64) #0
95 attributes #0 = { inaccessiblememonly nounwind willreturn }