1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=dse -S | FileCheck %s
4 @BUFFER = external local_unnamed_addr global [0 x i8], align 1
6 define void @ArrayTestFullyOverlapping(i64 %0) {
8 ; The DSE pass will try to kill the store of size i32 using the store of
9 ; size i64 because they fully overlap, in fact:
11 ; - they use the same base pointer (in SCEV style '@BUFFER + %0')
12 ; - the offset between the two stores is 32 bits
13 ; - the size of the earlier store is 32 bits
14 ; - the size of the later store is 64 bits
16 ; CHECK-LABEL: @ArrayTestFullyOverlapping(
17 ; CHECK-NEXT: [[TMP2:%.*]] = add i64 [[TMP0:%.*]], -8
18 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 [[TMP2]]
19 ; CHECK-NEXT: store i64 0, ptr [[TMP3]], align 4
20 ; CHECK-NEXT: ret void
23 %3 = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 %2
25 %5 = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 %4
31 define void @VectorTestFullyOverlapping(ptr %arg, i32 %i) {
32 ; CHECK-LABEL: @VectorTestFullyOverlapping(
34 ; CHECK-NEXT: [[I2:%.*]] = zext i32 [[I:%.*]] to i64
35 ; CHECK-NEXT: [[I3:%.*]] = getelementptr inbounds float, ptr [[ARG:%.*]], i64 [[I2]]
36 ; CHECK-NEXT: store <2 x float> zeroinitializer, ptr [[I3]], align 16
37 ; CHECK-NEXT: ret void
40 %i7 = add nuw nsw i32 %i, 1
41 %i8 = zext i32 %i7 to i64
42 %i9 = getelementptr inbounds float, ptr %arg, i64 %i8
43 store float 0.0, ptr %i9, align 4
44 %i2 = zext i32 %i to i64
45 %i3 = getelementptr inbounds float, ptr %arg, i64 %i2
46 store <2 x float> <float 0.0, float 0.0>, ptr %i3, align 16
50 define void @ArrayTestPartiallyOverlapping(i64 %0) {
52 ; The DSE pass will not kill the store because the overlap is partial
53 ; and won't fully clobber the i32 store.
55 ; CHECK-LABEL: @ArrayTestPartiallyOverlapping(
56 ; CHECK-NEXT: [[TMP2:%.*]] = add i64 [[TMP0:%.*]], 10
57 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 [[TMP2]]
58 ; CHECK-NEXT: [[TMP5:%.*]] = add i64 [[TMP0]], 15
59 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 [[TMP5]]
60 ; CHECK-NEXT: store i32 1, ptr [[TMP6]], align 4
61 ; CHECK-NEXT: store i64 0, ptr [[TMP3]], align 4
62 ; CHECK-NEXT: ret void
65 %3 = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 %2
67 %5 = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 %4
73 define void @VectorTestPartiallyOverlapping(ptr %arg, i32 %i) {
75 ; The DSE pass will not kill the store because the overlap is partial
76 ; and won't fully clobber the original store.
78 ; CHECK-LABEL: @VectorTestPartiallyOverlapping(
80 ; CHECK-NEXT: [[I2:%.*]] = zext i32 [[I:%.*]] to i64
81 ; CHECK-NEXT: [[I3:%.*]] = getelementptr inbounds float, ptr [[ARG:%.*]], i64 [[I2]]
82 ; CHECK-NEXT: store <2 x float> <float 1.000000e+00, float 1.000000e+00>, ptr [[I3]], align 16
83 ; CHECK-NEXT: [[I5:%.*]] = add nuw nsw i32 [[I]], 1
84 ; CHECK-NEXT: [[I6:%.*]] = zext i32 [[I5]] to i64
85 ; CHECK-NEXT: [[I7:%.*]] = getelementptr inbounds float, ptr [[ARG]], i64 [[I6]]
86 ; CHECK-NEXT: store <2 x float> zeroinitializer, ptr [[I7]], align 16
87 ; CHECK-NEXT: ret void
90 %i2 = zext i32 %i to i64
91 %i3 = getelementptr inbounds float, ptr %arg, i64 %i2
92 store <2 x float> <float 1.000000e+00, float 1.000000e+00>, ptr %i3, align 16
93 %i5 = add nuw nsw i32 %i, 1
94 %i6 = zext i32 %i5 to i64
95 %i7 = getelementptr inbounds float, ptr %arg, i64 %i6
96 store <2 x float> <float 0.0, float 0.0>, ptr %i7, align 16