209 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=dse -S | FileCheck %s3 4@BUFFER = external local_unnamed_addr global [0 x i8], align 15 6define void @ArrayTestFullyOverlapping(i64 %0) {7;8; The DSE pass will try to kill the store of size i32 using the store of9; 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 bits13; - the size of the earlier store is 32 bits14; - the size of the later store is 64 bits15;16; CHECK-LABEL: @ArrayTestFullyOverlapping(17; CHECK-NEXT: [[TMP2:%.*]] = add i64 [[TMP0:%.*]], -818; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 [[TMP2]]19; CHECK-NEXT: store i64 0, ptr [[TMP3]], align 420; CHECK-NEXT: ret void21;22 %2 = add i64 %0, -823 %3 = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 %224 %4 = add i64 %0, -425 %5 = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 %426 store i32 1, ptr %527 store i64 0, ptr %328 ret void29}30 31define void @VectorTestFullyOverlapping(ptr %arg, i32 %i) {32; CHECK-LABEL: @VectorTestFullyOverlapping(33; CHECK-NEXT: bb:34; CHECK-NEXT: [[I2:%.*]] = zext i32 [[I:%.*]] to i6435; CHECK-NEXT: [[I3:%.*]] = getelementptr inbounds float, ptr [[ARG:%.*]], i64 [[I2]]36; CHECK-NEXT: store <2 x float> zeroinitializer, ptr [[I3]], align 1637; CHECK-NEXT: ret void38;39bb:40 %i7 = add nuw nsw i32 %i, 141 %i8 = zext i32 %i7 to i6442 %i9 = getelementptr inbounds float, ptr %arg, i64 %i843 store float 0.0, ptr %i9, align 444 %i2 = zext i32 %i to i6445 %i3 = getelementptr inbounds float, ptr %arg, i64 %i246 store <2 x float> <float 0.0, float 0.0>, ptr %i3, align 1647 ret void48}49 50define void @ScalableVectorTestFullyOverlapping(ptr %arg, i32 %i) vscale_range(1, 2) {51; CHECK-LABEL: @ScalableVectorTestFullyOverlapping(52; CHECK-NEXT: [[I_1:%.*]] = add nuw nsw i32 [[I:%.*]], 153; CHECK-NEXT: [[EXT_I_1:%.*]] = zext i32 [[I_1]] to i6454; CHECK-NEXT: [[GEP_ARG_I_1:%.*]] = getelementptr inbounds float, ptr [[ARG:%.*]], i64 [[EXT_I_1]]55; CHECK-NEXT: store float 0.000000e+00, ptr [[GEP_ARG_I_1]], align 456; CHECK-NEXT: [[EXT_I:%.*]] = zext i32 [[I]] to i6457; CHECK-NEXT: [[GEP_ARG_I:%.*]] = getelementptr inbounds float, ptr [[ARG]], i64 [[EXT_I]]58; CHECK-NEXT: store <vscale x 2 x float> zeroinitializer, ptr [[GEP_ARG_I]], align 859; CHECK-NEXT: ret void60;61 %i.1 = add nuw nsw i32 %i, 162 %ext.i.1 = zext i32 %i.1 to i6463 %gep.arg.i.1 = getelementptr inbounds float, ptr %arg, i64 %ext.i.164 store float 0.0, ptr %gep.arg.i.165 %ext.i = zext i32 %i to i6466 %gep.arg.i = getelementptr inbounds float, ptr %arg, i64 %ext.i67 store <vscale x 2 x float> zeroinitializer, ptr %gep.arg.i68 ret void69}70 71define void @ScalableVectorTestFullyOverlapping2(ptr %arg, i32 %i) {72; CHECK-LABEL: @ScalableVectorTestFullyOverlapping2(73; CHECK-NEXT: [[I_1:%.*]] = add nuw nsw i32 [[I:%.*]], 174; CHECK-NEXT: [[EXT_I_1:%.*]] = zext i32 [[I_1]] to i6475; CHECK-NEXT: [[GEP_ARG_I_1:%.*]] = getelementptr inbounds float, ptr [[ARG:%.*]], i64 [[EXT_I_1]]76; CHECK-NEXT: store <vscale x 2 x float> zeroinitializer, ptr [[GEP_ARG_I_1]], align 877; CHECK-NEXT: [[EXT_I:%.*]] = zext i32 [[I]] to i6478; CHECK-NEXT: [[GEP_ARG_I:%.*]] = getelementptr inbounds float, ptr [[ARG]], i64 [[EXT_I]]79; CHECK-NEXT: store <vscale x 4 x float> zeroinitializer, ptr [[GEP_ARG_I]], align 1680; CHECK-NEXT: ret void81;82 %i.1 = add nuw nsw i32 %i, 183 %ext.i.1 = zext i32 %i.1 to i6484 %gep.arg.i.1 = getelementptr inbounds float, ptr %arg, i64 %ext.i.185 store <vscale x 2 x float> zeroinitializer, ptr %gep.arg.i.186 %ext.i = zext i32 %i to i6487 %gep.arg.i = getelementptr inbounds float, ptr %arg, i64 %ext.i88 store <vscale x 4 x float> zeroinitializer, ptr %gep.arg.i89 ret void90}91 92define void @ScalableVectorTestNonOverlapping(ptr %arg, i32 %i) vscale_range(1, 2) {93; CHECK-LABEL: @ScalableVectorTestNonOverlapping(94; CHECK-NEXT: [[I_10:%.*]] = add nuw nsw i32 [[I:%.*]], 1095; CHECK-NEXT: [[EXT_I_10:%.*]] = zext i32 [[I_10]] to i6496; CHECK-NEXT: [[GEP_ARG_I_10:%.*]] = getelementptr inbounds float, ptr [[ARG:%.*]], i64 [[EXT_I_10]]97; CHECK-NEXT: store float 0.000000e+00, ptr [[GEP_ARG_I_10]], align 498; CHECK-NEXT: [[EXT_I:%.*]] = zext i32 [[I]] to i6499; CHECK-NEXT: [[GEP_ARG_I:%.*]] = getelementptr inbounds float, ptr [[ARG]], i64 [[EXT_I]]100; CHECK-NEXT: store <vscale x 2 x float> zeroinitializer, ptr [[GEP_ARG_I]], align 8101; CHECK-NEXT: ret void102;103 %i.10 = add nuw nsw i32 %i, 10104 %ext.i.10 = zext i32 %i.10 to i64105 %gep.arg.i.10 = getelementptr inbounds float, ptr %arg, i64 %ext.i.10106 store float 0.0, ptr %gep.arg.i.10107 %ext.i = zext i32 %i to i64108 %gep.arg.i = getelementptr inbounds float, ptr %arg, i64 %ext.i109 store <vscale x 2 x float> zeroinitializer, ptr %gep.arg.i110 ret void111}112 113define void @ScalableVectorTestNonOverlapping2(ptr %arg, i32 %i) vscale_range(1, 2) {114; CHECK-LABEL: @ScalableVectorTestNonOverlapping2(115; CHECK-NEXT: [[I_10:%.*]] = add nuw nsw i32 [[I:%.*]], 10116; CHECK-NEXT: [[EXT_I_10:%.*]] = zext i32 [[I_10]] to i64117; CHECK-NEXT: [[GEP_ARG_I_10:%.*]] = getelementptr inbounds float, ptr [[ARG:%.*]], i64 [[EXT_I_10]]118; CHECK-NEXT: store <vscale x 2 x float> zeroinitializer, ptr [[GEP_ARG_I_10]], align 8119; CHECK-NEXT: [[EXT_I:%.*]] = zext i32 [[I]] to i64120; CHECK-NEXT: [[GEP_ARG_I:%.*]] = getelementptr inbounds float, ptr [[ARG]], i64 [[EXT_I]]121; CHECK-NEXT: store <vscale x 4 x float> zeroinitializer, ptr [[GEP_ARG_I]], align 16122; CHECK-NEXT: ret void123;124 %i.10 = add nuw nsw i32 %i, 10125 %ext.i.10 = zext i32 %i.10 to i64126 %gep.arg.i.10 = getelementptr inbounds float, ptr %arg, i64 %ext.i.10127 store <vscale x 2 x float> zeroinitializer, ptr %gep.arg.i.10128 %ext.i = zext i32 %i to i64129 %gep.arg.i = getelementptr inbounds float, ptr %arg, i64 %ext.i130 store <vscale x 4 x float> zeroinitializer, ptr %gep.arg.i131 ret void132}133 134define void @ArrayTestPartiallyOverlapping(i64 %0) {135;136; The DSE pass will not kill the store because the overlap is partial137; and won't fully clobber the i32 store.138;139; CHECK-LABEL: @ArrayTestPartiallyOverlapping(140; CHECK-NEXT: [[TMP2:%.*]] = add i64 [[TMP0:%.*]], 10141; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 [[TMP2]]142; CHECK-NEXT: [[TMP4:%.*]] = add i64 [[TMP0]], 15143; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 [[TMP4]]144; CHECK-NEXT: store i32 1, ptr [[TMP5]], align 4145; CHECK-NEXT: store i64 0, ptr [[TMP3]], align 4146; CHECK-NEXT: ret void147;148 %2 = add i64 %0, 10149 %3 = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 %2150 %4 = add i64 %0, 15151 %5 = getelementptr inbounds [0 x i8], ptr @BUFFER, i64 0, i64 %4152 store i32 1, ptr %5153 store i64 0, ptr %3154 ret void155}156 157define void @VectorTestPartiallyOverlapping(ptr %arg, i32 %i) {158;159; The DSE pass will not kill the store because the overlap is partial160; and won't fully clobber the original store.161;162; CHECK-LABEL: @VectorTestPartiallyOverlapping(163; CHECK-NEXT: bb:164; CHECK-NEXT: [[I2:%.*]] = zext i32 [[I:%.*]] to i64165; CHECK-NEXT: [[I3:%.*]] = getelementptr inbounds float, ptr [[ARG:%.*]], i64 [[I2]]166; CHECK-NEXT: store <2 x float> splat (float 1.000000e+00), ptr [[I3]], align 16167; CHECK-NEXT: [[I5:%.*]] = add nuw nsw i32 [[I]], 1168; CHECK-NEXT: [[I6:%.*]] = zext i32 [[I5]] to i64169; CHECK-NEXT: [[I7:%.*]] = getelementptr inbounds float, ptr [[ARG]], i64 [[I6]]170; CHECK-NEXT: store <2 x float> zeroinitializer, ptr [[I7]], align 16171; CHECK-NEXT: ret void172;173bb:174 %i2 = zext i32 %i to i64175 %i3 = getelementptr inbounds float, ptr %arg, i64 %i2176 store <2 x float> <float 1.000000e+00, float 1.000000e+00>, ptr %i3, align 16177 %i5 = add nuw nsw i32 %i, 1178 %i6 = zext i32 %i5 to i64179 %i7 = getelementptr inbounds float, ptr %arg, i64 %i6180 store <2 x float> <float 0.0, float 0.0>, ptr %i7, align 16181 ret void182}183 184define void @ScalableVectorTestPartiallyOverlapping(ptr %arg, i32 %i) {185;186; The DSE pass will not kill the store because the overlap is partial187; and won't fully clobber the original store.188;189; CHECK-LABEL: @ScalableVectorTestPartiallyOverlapping(190; CHECK-NEXT: [[EXT_I:%.*]] = zext i32 [[I:%.*]] to i64191; CHECK-NEXT: [[GEP_ARG_I:%.*]] = getelementptr inbounds float, ptr [[ARG:%.*]], i64 [[EXT_I]]192; CHECK-NEXT: store <vscale x 2 x float> zeroinitializer, ptr [[GEP_ARG_I]], align 8193; CHECK-NEXT: [[I_1:%.*]] = add nuw nsw i32 [[I]], 1194; CHECK-NEXT: [[EXT_I_1:%.*]] = zext i32 [[I_1]] to i64195; CHECK-NEXT: [[GEP_ARG_I_1:%.*]] = getelementptr inbounds float, ptr [[ARG]], i64 [[EXT_I_1]]196; CHECK-NEXT: store <vscale x 2 x float> zeroinitializer, ptr [[GEP_ARG_I_1]], align 8197; CHECK-NEXT: ret void198;199 %ext.i = zext i32 %i to i64200 %gep.arg.i = getelementptr inbounds float, ptr %arg, i64 %ext.i201 store <vscale x 2 x float> zeroinitializer, ptr %gep.arg.i202 %i.1 = add nuw nsw i32 %i, 1203 %ext.i.1 = zext i32 %i.1 to i64204 %gep.arg.i.1 = getelementptr inbounds float, ptr %arg, i64 %ext.i.1205 store <vscale x 2 x float> zeroinitializer, ptr %gep.arg.i.1206 ret void207}208 209