multiblock-overlap.ll
8.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -dse -enable-dse-memoryssa %s -S | FileCheck --check-prefixes=CHECK,DEFAULT-LIMIT %s
; RUN: opt -dse -enable-dse-memoryssa -dse-memoryssa-partial-store-limit=10 %s -S | FileCheck --check-prefixes=CHECK,LARGER-LIMIT %s
%struct.ham = type { [3 x double], [3 x double]}
declare void @may_throw()
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg)
; We miss this case, because of an aggressive limit of partial overlap analysis.
; With a larger partial store limit, we remove the memset.
define void @overlap1(%struct.ham* %arg, i1 %cond) {
; DEFAULT-LIMIT-LABEL: @overlap1(
; DEFAULT-LIMIT-NEXT: bb:
; DEFAULT-LIMIT-NEXT: [[TMP:%.*]] = getelementptr inbounds [[STRUCT_HAM:%.*]], %struct.ham* [[ARG:%.*]], i64 0, i32 0, i64 2
; DEFAULT-LIMIT-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 0, i64 1
; DEFAULT-LIMIT-NEXT: [[TMP2:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 0, i64 0
; DEFAULT-LIMIT-NEXT: [[TMP3:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 1, i64 2
; DEFAULT-LIMIT-NEXT: [[TMP4:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 1, i64 1
; DEFAULT-LIMIT-NEXT: [[TMP5:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 1, i32 0
; DEFAULT-LIMIT-NEXT: [[TMP6:%.*]] = bitcast double* [[TMP2]] to i8*
; DEFAULT-LIMIT-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, i8* [[TMP6]], i64 32
; DEFAULT-LIMIT-NEXT: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(48) [[TMP0]], i8 0, i64 16, i1 false)
; DEFAULT-LIMIT-NEXT: br i1 [[COND:%.*]], label [[BB7:%.*]], label [[BB8:%.*]]
; DEFAULT-LIMIT: bb7:
; DEFAULT-LIMIT-NEXT: br label [[BB9:%.*]]
; DEFAULT-LIMIT: bb8:
; DEFAULT-LIMIT-NEXT: br label [[BB9]]
; DEFAULT-LIMIT: bb9:
; DEFAULT-LIMIT-NEXT: store double 1.000000e+00, double* [[TMP2]], align 8
; DEFAULT-LIMIT-NEXT: store double 2.000000e+00, double* [[TMP1]], align 8
; DEFAULT-LIMIT-NEXT: store double 3.000000e+00, double* [[TMP]], align 8
; DEFAULT-LIMIT-NEXT: store double 4.000000e+00, double* [[TMP5]], align 8
; DEFAULT-LIMIT-NEXT: store double 5.000000e+00, double* [[TMP4]], align 8
; DEFAULT-LIMIT-NEXT: store double 6.000000e+00, double* [[TMP3]], align 8
; DEFAULT-LIMIT-NEXT: ret void
;
; LARGER-LIMIT-LABEL: @overlap1(
; LARGER-LIMIT-NEXT: bb:
; LARGER-LIMIT-NEXT: [[TMP:%.*]] = getelementptr inbounds [[STRUCT_HAM:%.*]], %struct.ham* [[ARG:%.*]], i64 0, i32 0, i64 2
; LARGER-LIMIT-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 0, i64 1
; LARGER-LIMIT-NEXT: [[TMP2:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 0, i64 0
; LARGER-LIMIT-NEXT: [[TMP3:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 1, i64 2
; LARGER-LIMIT-NEXT: [[TMP4:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 1, i64 1
; LARGER-LIMIT-NEXT: [[TMP5:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 1, i32 0
; LARGER-LIMIT-NEXT: br i1 [[COND:%.*]], label [[BB7:%.*]], label [[BB8:%.*]]
; LARGER-LIMIT: bb7:
; LARGER-LIMIT-NEXT: br label [[BB9:%.*]]
; LARGER-LIMIT: bb8:
; LARGER-LIMIT-NEXT: br label [[BB9]]
; LARGER-LIMIT: bb9:
; LARGER-LIMIT-NEXT: store double 1.000000e+00, double* [[TMP2]], align 8
; LARGER-LIMIT-NEXT: store double 2.000000e+00, double* [[TMP1]], align 8
; LARGER-LIMIT-NEXT: store double 3.000000e+00, double* [[TMP]], align 8
; LARGER-LIMIT-NEXT: store double 4.000000e+00, double* [[TMP5]], align 8
; LARGER-LIMIT-NEXT: store double 5.000000e+00, double* [[TMP4]], align 8
; LARGER-LIMIT-NEXT: store double 6.000000e+00, double* [[TMP3]], align 8
; LARGER-LIMIT-NEXT: ret void
;
bb:
%tmp = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0, i32 0, i64 2
%tmp1 = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0, i32 0, i64 1
%tmp2 = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0, i32 0, i64 0
%tmp3 = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0,i32 1, i64 2
%tmp4 = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0, i32 1, i64 1
%tmp5 = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0, i32 1, i32 0
%tmp6 = bitcast double* %tmp2 to i8*
call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(48) %tmp6, i8 0, i64 48, i1 false)
br i1 %cond, label %bb7, label %bb8
bb7: ; preds = %bb
br label %bb9
bb8: ; preds = %bb
br label %bb9
bb9: ; preds = %bb8, %bb7
store double 1.0, double* %tmp2, align 8
store double 2.0, double* %tmp1, align 8
store double 3.0, double* %tmp, align 8
store double 4.0, double* %tmp5, align 8
store double 5.0, double* %tmp4, align 8
store double 6.0, double* %tmp3, align 8
ret void
}
define void @overlap2(%struct.ham* %arg, i1 %cond) {
; CHECK-LABEL: @overlap2(
; CHECK-NEXT: bb:
; CHECK-NEXT: [[TMP:%.*]] = getelementptr inbounds [[STRUCT_HAM:%.*]], %struct.ham* [[ARG:%.*]], i64 0, i32 0, i64 2
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 0, i64 1
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 0, i64 0
; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 1, i64 2
; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 1, i64 1
; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds [[STRUCT_HAM]], %struct.ham* [[ARG]], i64 0, i32 1, i32 0
; CHECK-NEXT: [[TMP6:%.*]] = bitcast double* [[TMP2]] to i8*
; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(48) [[TMP6]], i8 0, i64 48, i1 false)
; CHECK-NEXT: br i1 [[COND:%.*]], label [[BB7:%.*]], label [[BB8:%.*]]
; CHECK: bb7:
; CHECK-NEXT: call void @may_throw()
; CHECK-NEXT: br label [[BB9:%.*]]
; CHECK: bb8:
; CHECK-NEXT: br label [[BB9]]
; CHECK: bb9:
; CHECK-NEXT: store double 1.000000e+00, double* [[TMP2]], align 8
; CHECK-NEXT: store double 2.000000e+00, double* [[TMP1]], align 8
; CHECK-NEXT: store double 3.000000e+00, double* [[TMP]], align 8
; CHECK-NEXT: store double 4.000000e+00, double* [[TMP5]], align 8
; CHECK-NEXT: store double 5.000000e+00, double* [[TMP4]], align 8
; CHECK-NEXT: store double 6.000000e+00, double* [[TMP3]], align 8
; CHECK-NEXT: ret void
;
bb:
%tmp = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0, i32 0, i64 2
%tmp1 = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0, i32 0, i64 1
%tmp2 = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0, i32 0, i64 0
%tmp3 = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0,i32 1, i64 2
%tmp4 = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0, i32 1, i64 1
%tmp5 = getelementptr inbounds %struct.ham, %struct.ham* %arg, i64 0, i32 1, i32 0
%tmp6 = bitcast double* %tmp2 to i8*
call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(48) %tmp6, i8 0, i64 48, i1 false)
br i1 %cond, label %bb7, label %bb8
bb7: ; preds = %bb
call void @may_throw()
br label %bb9
bb8: ; preds = %bb
br label %bb9
bb9: ; preds = %bb8, %bb7
store double 1.0, double* %tmp2, align 8
store double 2.0, double* %tmp1, align 8
store double 3.0, double* %tmp, align 8
store double 4.0, double* %tmp5, align 8
store double 5.0, double* %tmp4, align 8
store double 6.0, double* %tmp3, align 8
ret void
}
; Test case from PR46513. Make sure we do not crash.
; TODO: we should be able to shorten store i32 844283136, i32* %cast.i32 to a
; store of i16.
define void @overlap_no_dominance([4 x i8]* %arg, i1 %c) {
; CHECK-LABEL: @overlap_no_dominance(
; CHECK-NEXT: bb:
; CHECK-NEXT: br i1 [[C:%.*]], label [[BB13:%.*]], label [[BB9:%.*]]
; CHECK: bb9:
; CHECK-NEXT: [[CAST_I32:%.*]] = bitcast [4 x i8]* [[ARG:%.*]] to i32*
; CHECK-NEXT: store i32 844283136, i32* [[CAST_I32]], align 4
; CHECK-NEXT: br label [[BB13]]
; CHECK: bb13:
; CHECK-NEXT: [[CAST_I16:%.*]] = bitcast [4 x i8]* [[ARG]] to i16*
; CHECK-NEXT: store i16 0, i16* [[CAST_I16]], align 4
; CHECK-NEXT: ret void
;
bb:
br i1 %c, label %bb13, label %bb9
bb9: ; preds = %bb
%cast.i32 = bitcast [4 x i8]* %arg to i32*
store i32 844283136, i32* %cast.i32, align 4
br label %bb13
bb13: ; preds = %bb9, %bb
%cast.i16 = bitcast [4 x i8]* %arg to i16*
store i16 0, i16* %cast.i16, align 4
ret void
}