1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -dse -S | FileCheck %s 3 4@BUFFER = external local_unnamed_addr global [0 x i8], align 1 5 6define void @ArrayTestFullyOverlapping(i64 %0) { 7; 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: 10; 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 15; 16; CHECK-LABEL: @ArrayTestFullyOverlapping( 17; CHECK-NEXT: [[TMP2:%.*]] = add i64 [[TMP0:%.*]], -8 18; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 [[TMP2]] 19; CHECK-NEXT: [[TMP4:%.*]] = bitcast i8* [[TMP3]] to i64* 20; CHECK-NEXT: store i64 0, i64* [[TMP4]], align 4 21; CHECK-NEXT: ret void 22; 23 %2 = add i64 %0, -8 24 %3 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %2 25 %4 = bitcast i8* %3 to i64* 26 %5 = add i64 %0, -4 27 %6 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %5 28 %7 = bitcast i8* %6 to i32* 29 store i32 1, i32* %7 30 store i64 0, i64* %4 31 ret void 32} 33 34define void @VectorTestFullyOverlapping(float* %arg, i32 %i) { 35; CHECK-LABEL: @VectorTestFullyOverlapping( 36; CHECK-NEXT: bb: 37; CHECK-NEXT: [[I2:%.*]] = zext i32 [[I:%.*]] to i64 38; CHECK-NEXT: [[I3:%.*]] = getelementptr inbounds float, float* [[ARG:%.*]], i64 [[I2]] 39; CHECK-NEXT: [[I4:%.*]] = bitcast float* [[I3]] to <2 x float>* 40; CHECK-NEXT: store <2 x float> zeroinitializer, <2 x float>* [[I4]], align 16 41; CHECK-NEXT: ret void 42; 43bb: 44 %i7 = add nuw nsw i32 %i, 1 45 %i8 = zext i32 %i7 to i64 46 %i9 = getelementptr inbounds float, float* %arg, i64 %i8 47 store float 0.0, float* %i9, align 4 48 %i2 = zext i32 %i to i64 49 %i3 = getelementptr inbounds float, float* %arg, i64 %i2 50 %i4 = bitcast float* %i3 to <2 x float>* 51 store <2 x float> <float 0.0, float 0.0>, <2 x float>* %i4, align 16 52 ret void 53} 54 55define void @ArrayTestPartiallyOverlapping(i64 %0) { 56; 57; The DSE pass will not kill the store because the overlap is partial 58; and won't fully clobber the i32 store. 59; 60; CHECK-LABEL: @ArrayTestPartiallyOverlapping( 61; CHECK-NEXT: [[TMP2:%.*]] = add i64 [[TMP0:%.*]], 10 62; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 [[TMP2]] 63; CHECK-NEXT: [[TMP4:%.*]] = bitcast i8* [[TMP3]] to i64* 64; CHECK-NEXT: [[TMP5:%.*]] = add i64 [[TMP0]], 15 65; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 [[TMP5]] 66; CHECK-NEXT: [[TMP7:%.*]] = bitcast i8* [[TMP6]] to i32* 67; CHECK-NEXT: store i32 1, i32* [[TMP7]], align 4 68; CHECK-NEXT: store i64 0, i64* [[TMP4]], align 4 69; CHECK-NEXT: ret void 70; 71 %2 = add i64 %0, 10 72 %3 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %2 73 %4 = bitcast i8* %3 to i64* 74 %5 = add i64 %0, 15 75 %6 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %5 76 %7 = bitcast i8* %6 to i32* 77 store i32 1, i32* %7 78 store i64 0, i64* %4 79 ret void 80} 81 82define void @VectorTestPartiallyOverlapping(float* %arg, i32 %i) { 83; 84; The DSE pass will not kill the store because the overlap is partial 85; and won't fully clobber the original store. 86; 87; CHECK-LABEL: @VectorTestPartiallyOverlapping( 88; CHECK-NEXT: bb: 89; CHECK-NEXT: [[I2:%.*]] = zext i32 [[I:%.*]] to i64 90; CHECK-NEXT: [[I3:%.*]] = getelementptr inbounds float, float* [[ARG:%.*]], i64 [[I2]] 91; CHECK-NEXT: [[I4:%.*]] = bitcast float* [[I3]] to <2 x float>* 92; CHECK-NEXT: store <2 x float> <float 1.000000e+00, float 1.000000e+00>, <2 x float>* [[I4]], align 16 93; CHECK-NEXT: [[I5:%.*]] = add nuw nsw i32 [[I]], 1 94; CHECK-NEXT: [[I6:%.*]] = zext i32 [[I5]] to i64 95; CHECK-NEXT: [[I7:%.*]] = getelementptr inbounds float, float* [[ARG]], i64 [[I6]] 96; CHECK-NEXT: [[I8:%.*]] = bitcast float* [[I7]] to <2 x float>* 97; CHECK-NEXT: store <2 x float> zeroinitializer, <2 x float>* [[I8]], align 16 98; CHECK-NEXT: ret void 99; 100bb: 101 %i2 = zext i32 %i to i64 102 %i3 = getelementptr inbounds float, float* %arg, i64 %i2 103 %i4 = bitcast float* %i3 to <2 x float>* 104 store <2 x float> <float 1.000000e+00, float 1.000000e+00>, <2 x float>* %i4, align 16 105 %i5 = add nuw nsw i32 %i, 1 106 %i6 = zext i32 %i5 to i64 107 %i7 = getelementptr inbounds float, float* %arg, i64 %i6 108 %i8 = bitcast float* %i7 to <2 x float>* 109 store <2 x float> <float 0.0, float 0.0>, <2 x float>* %i8, align 16 110 ret void 111} 112 113