1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instcombine -available-load-scan-limit=2 -S < %s | FileCheck %s
4 %struct.nonbonded = type { [2 x ptr], [2 x ptr], [2 x ptr], [2 x ptr], [2 x ptr], [2 x i32], %class.Vector, ptr, ptr, ptr, ptr, i32, i32, double, double, i32, i32, i32, i32 }
5 %struct.CompAtomExt = type { i32 }
6 %struct.CompAtom = type { %class.Vector, float, i16, i8, i8 }
7 %class.Vector = type { double, double, double }
8 %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 }
9 %class.ResizeArray.0 = type { ptr, ptr }
10 %class.ResizeArrayRaw.1 = type <{ ptr, ptr, i32, i32, i32, float, i32, [4 x i8] }>
11 %class.ResizeArray = type { ptr, ptr }
12 %class.ResizeArrayRaw = type <{ ptr, ptr, i32, i32, i32, float, i32, [4 x i8] }>
13 %class.ResizeArray.2 = type { ptr, ptr }
14 %class.ResizeArrayRaw.3 = type <{ ptr, ptr, i32, i32, i32, float, i32, [4 x i8] }>
15 %class.Pairlists = type { ptr, i32, i32 }
17 ;; Check the minPart4 and minPart assignments are merged.
18 define dso_local void @merge(ptr nocapture readonly %params) local_unnamed_addr align 2 {
19 ; CHECK-LABEL: @merge(
21 ; CHECK-NEXT: [[SAVEPAIRLISTS3:%.*]] = getelementptr inbounds [[STRUCT_NONBONDED:%.*]], ptr [[PARAMS:%.*]], i64 0, i32 11
22 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[SAVEPAIRLISTS3]], align 8
23 ; CHECK-NEXT: [[USEPAIRLISTS4:%.*]] = getelementptr inbounds [[STRUCT_NONBONDED]], ptr [[PARAMS]], i64 0, i32 12
24 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[USEPAIRLISTS4]], align 4
25 ; CHECK-NEXT: [[TOBOOL54_NOT:%.*]] = icmp eq i32 [[TMP0]], 0
26 ; CHECK-NEXT: br i1 [[TOBOOL54_NOT]], label [[LOR_LHS_FALSE55:%.*]], label [[IF_END109:%.*]]
27 ; CHECK: lor.lhs.false55:
28 ; CHECK-NEXT: [[TOBOOL56_NOT:%.*]] = icmp eq i32 [[TMP1]], 0
29 ; CHECK-NEXT: br i1 [[TOBOOL56_NOT]], label [[IF_END109]], label [[IF_END109_THREAD:%.*]]
30 ; CHECK: if.end109.thread:
31 ; CHECK-NEXT: call void @llvm.pseudoprobe(i64 -6172701105289426098, i64 2, i32 0, i64 -1)
32 ; CHECK-NEXT: br label [[IF_THEN138:%.*]]
34 ; CHECK-NEXT: call void @llvm.pseudoprobe(i64 -6172701105289426098, i64 3, i32 0, i64 -1)
35 ; CHECK-NEXT: [[TOBOOL116_NOT:%.*]] = icmp eq i32 [[TMP1]], 0
36 ; CHECK-NEXT: br i1 [[TOBOOL116_NOT]], label [[IF_THEN117:%.*]], label [[IF_THEN138]]
38 ; CHECK-NEXT: ret void
40 ; CHECK-NEXT: [[DOTIN:%.*]] = getelementptr inbounds [[STRUCT_NONBONDED]], ptr [[PARAMS]], i64 0, i32 16
41 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[DOTIN]], align 4
42 ; CHECK-NEXT: [[TOBOOL139_NOT:%.*]] = icmp eq i32 [[TMP2]], 0
43 ; CHECK-NEXT: br i1 [[TOBOOL139_NOT]], label [[IF_ELSE147:%.*]], label [[IF_THEN140:%.*]]
45 ; CHECK-NEXT: ret void
47 ; CHECK-NEXT: ret void
50 %savePairlists3 = getelementptr inbounds %struct.nonbonded, ptr %params, i64 0, i32 11
51 %0 = load i32, ptr %savePairlists3, align 8
52 %usePairlists4 = getelementptr inbounds %struct.nonbonded, ptr %params, i64 0, i32 12
53 %1 = load i32, ptr %usePairlists4, align 4
54 %tobool54.not = icmp eq i32 %0, 0
55 br i1 %tobool54.not, label %lor.lhs.false55, label %if.end109
57 lor.lhs.false55: ; preds = %entry
58 %tobool56.not = icmp eq i32 %1, 0
59 br i1 %tobool56.not, label %if.end109, label %if.end109.thread
61 if.end109.thread: ; preds = %lor.lhs.false55
62 %minPart4 = getelementptr inbounds %struct.nonbonded, ptr %params, i64 0, i32 16
63 %2 = load i32, ptr %minPart4, align 4
64 call void @llvm.pseudoprobe(i64 -6172701105289426098, i64 2, i32 0, i64 -1)
67 if.end109: ; preds = %lor.lhs.false55, %entry
68 %minPart = getelementptr inbounds %struct.nonbonded, ptr %params, i64 0, i32 16
69 %3 = load i32, ptr %minPart, align 4
70 call void @llvm.pseudoprobe(i64 -6172701105289426098, i64 3, i32 0, i64 -1)
71 %tobool116.not = icmp eq i32 %1, 0
72 br i1 %tobool116.not, label %if.then117, label %if.then138
74 if.then117: ; preds = %if.end109
77 if.then138: ; preds = %if.end109.thread, %if.end109
78 %4 = phi i32 [ %2, %if.end109.thread ], [ %3, %if.end109 ]
79 %tobool139.not = icmp eq i32 %4, 0
80 br i1 %tobool139.not, label %if.else147, label %if.then140
82 if.then140: ; preds = %if.then138
85 if.else147: ; preds = %if.then138
89 ;; Check the last store is deleted.
90 define i32 @load(ptr nocapture %a, ptr nocapture %b) {
92 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 1
93 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[TMP1]], align 8
94 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i32, ptr [[B:%.*]], i64 1
95 ; CHECK-NEXT: store i32 [[TMP2]], ptr [[TMP3]], align 8
96 ; CHECK-NEXT: call void @llvm.pseudoprobe(i64 5116412291814990879, i64 1, i32 0, i64 -1)
97 ; CHECK-NEXT: ret i32 [[TMP2]]
99 %1 = getelementptr inbounds i32, ptr %a, i32 1
100 %2 = load i32, ptr %1, align 8
101 %3 = getelementptr inbounds i32, ptr %b, i32 1
102 store i32 %2, ptr %3, align 8
103 %4 = getelementptr inbounds i32, ptr %b, i32 1
104 call void @llvm.pseudoprobe(i64 5116412291814990879, i64 1, i32 0, i64 -1)
105 %5 = load i32, ptr %4, align 8
109 ;; Check the first store is deleted.
110 define void @dse(ptr %p) {
112 ; CHECK-NEXT: call void @llvm.pseudoprobe(i64 5116412291814990879, i64 1, i32 0, i64 -1)
113 ; CHECK-NEXT: store i32 0, ptr [[P:%.*]], align 4
114 ; CHECK-NEXT: ret void
117 call void @llvm.pseudoprobe(i64 5116412291814990879, i64 1, i32 0, i64 -1)
122 ; Function Attrs: inaccessiblememonly nounwind willreturn
123 declare void @llvm.pseudoprobe(i64, i64, i32, i64) #0
125 attributes #0 = { inaccessiblememonly nounwind willreturn }