199 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake-avx512 | FileCheck %s3 4%struct.S = type { [8 x i32], [8 x i32], [16 x i32] }5 6define dso_local void @_Z4testP1S(ptr %p) local_unnamed_addr {7; CHECK-LABEL: @_Z4testP1S(8; CHECK-NEXT: entry:9; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], ptr [[P:%.*]], i64 0, i32 1, i64 010; CHECK-NEXT: [[ARRAYIDX20:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[P]], i64 0, i32 2, i64 411; CHECK-NEXT: [[TMP2:%.*]] = load <8 x i32>, ptr [[ARRAYIDX]], align 412; CHECK-NEXT: [[TMP1:%.*]] = call <12 x i32> @llvm.masked.load.v12i32.p0(ptr align 4 [[ARRAYIDX20]], <12 x i1> <i1 true, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 false, i1 true, i1 true, i1 true, i1 true>, <12 x i32> poison)13; CHECK-NEXT: [[TMP6:%.*]] = shufflevector <12 x i32> [[TMP1]], <12 x i32> poison, <8 x i32> <i32 11, i32 3, i32 2, i32 0, i32 8, i32 9, i32 10, i32 1>14; CHECK-NEXT: [[TMP7:%.*]] = add nsw <8 x i32> [[TMP6]], [[TMP2]]15; CHECK-NEXT: store <8 x i32> [[TMP7]], ptr [[P]], align 416; CHECK-NEXT: ret void17;18entry:19 %arrayidx = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 1, i64 020 %i = load i32, ptr %arrayidx, align 421 %arrayidx1 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 2, i64 1522 %i1 = load i32, ptr %arrayidx1, align 423 %add = add nsw i32 %i1, %i24 store i32 %add, ptr %p, align 425 %arrayidx4 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 1, i64 126 %i2 = load i32, ptr %arrayidx4, align 427 %arrayidx6 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 2, i64 728 %i3 = load i32, ptr %arrayidx6, align 429 %add7 = add nsw i32 %i3, %i230 %arrayidx9 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 131 store i32 %add7, ptr %arrayidx9, align 432 %arrayidx11 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 1, i64 233 %i4 = load i32, ptr %arrayidx11, align 434 %arrayidx13 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 2, i64 635 %i5 = load i32, ptr %arrayidx13, align 436 %add14 = add nsw i32 %i5, %i437 %arrayidx16 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 238 store i32 %add14, ptr %arrayidx16, align 439 %arrayidx18 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 1, i64 340 %i6 = load i32, ptr %arrayidx18, align 441 %arrayidx20 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 2, i64 442 %i7 = load i32, ptr %arrayidx20, align 443 %add21 = add nsw i32 %i7, %i644 %arrayidx23 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 345 store i32 %add21, ptr %arrayidx23, align 446 %arrayidx25 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 1, i64 447 %i8 = load i32, ptr %arrayidx25, align 448 %arrayidx27 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 2, i64 1249 %i9 = load i32, ptr %arrayidx27, align 450 %add28 = add nsw i32 %i9, %i851 %arrayidx30 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 452 store i32 %add28, ptr %arrayidx30, align 453 %arrayidx32 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 1, i64 554 %i10 = load i32, ptr %arrayidx32, align 455 %arrayidx34 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 2, i64 1356 %i11 = load i32, ptr %arrayidx34, align 457 %add35 = add nsw i32 %i11, %i1058 %arrayidx37 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 559 store i32 %add35, ptr %arrayidx37, align 460 %arrayidx39 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 1, i64 661 %i12 = load i32, ptr %arrayidx39, align 462 %arrayidx41 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 2, i64 1463 %i13 = load i32, ptr %arrayidx41, align 464 %add42 = add nsw i32 %i13, %i1265 %arrayidx44 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 666 store i32 %add42, ptr %arrayidx44, align 467 %arrayidx46 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 1, i64 768 %i14 = load i32, ptr %arrayidx46, align 469 %arrayidx48 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 2, i64 570 %i15 = load i32, ptr %arrayidx48, align 471 %add49 = add nsw i32 %i15, %i1472 %arrayidx51 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 773 store i32 %add49, ptr %arrayidx51, align 474 ret void75}76 77; Test for 2 load groups 4 elements each against different base pointers.78; Both loaded groups are not ordered thus here are few specific points:79; (1) these groups are detected, (2) reordereing shuffles generated and80; (3) these loads vectorized as a part of tree that is seeded by stores81; and with VF=8.82 83define dso_local void @test_unordered_splits(ptr nocapture %p) local_unnamed_addr {84; CHECK-LABEL: @test_unordered_splits(85; CHECK-NEXT: entry:86; CHECK-NEXT: [[P1:%.*]] = alloca [16 x i32], align 1687; CHECK-NEXT: [[P2:%.*]] = alloca [16 x i32], align 1688; CHECK-NEXT: [[G10:%.*]] = getelementptr inbounds [16 x i32], ptr [[P1]], i32 0, i64 489; CHECK-NEXT: [[G20:%.*]] = getelementptr inbounds [16 x i32], ptr [[P2]], i32 0, i64 1290; CHECK-NEXT: [[TMP0:%.*]] = load <4 x i32>, ptr [[G10]], align 491; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[G20]], align 492; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP0]], <4 x i32> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison>93; CHECK-NEXT: [[TMP5:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison>94; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <4 x i32> [[TMP0]], <4 x i32> [[TMP1]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>95; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <8 x i32> [[TMP3]], <8 x i32> poison, <8 x i32> <i32 1, i32 0, i32 2, i32 3, i32 7, i32 5, i32 6, i32 4>96; CHECK-NEXT: store <8 x i32> [[TMP4]], ptr [[P:%.*]], align 497; CHECK-NEXT: ret void98;99entry:100 %p1 = alloca [16 x i32], align 16101 %p2 = alloca [16 x i32], align 16102 %g10 = getelementptr inbounds [16 x i32], ptr %p1, i32 0, i64 4103 %g11 = getelementptr inbounds [16 x i32], ptr %p1, i32 0, i64 5104 %g12 = getelementptr inbounds [16 x i32], ptr %p1, i32 0, i64 6105 %g13 = getelementptr inbounds [16 x i32], ptr %p1, i32 0, i64 7106 %g20 = getelementptr inbounds [16 x i32], ptr %p2, i32 0, i64 12107 %g21 = getelementptr inbounds [16 x i32], ptr %p2, i32 0, i64 13108 %g22 = getelementptr inbounds [16 x i32], ptr %p2, i32 0, i64 14109 %g23 = getelementptr inbounds [16 x i32], ptr %p2, i32 0, i64 15110 %i1 = load i32, ptr %g11, align 4111 store i32 %i1, ptr %p, align 4112 %i3 = load i32, ptr %g10, align 4113 %arrayidx9 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 1114 store i32 %i3, ptr %arrayidx9, align 4115 %i5 = load i32, ptr %g12, align 4116 %arrayidx16 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 2117 store i32 %i5, ptr %arrayidx16, align 4118 %i7 = load i32, ptr %g13, align 4119 %arrayidx23 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 3120 store i32 %i7, ptr %arrayidx23, align 4121 %i9 = load i32, ptr %g23, align 4122 %arrayidx30 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 4123 store i32 %i9, ptr %arrayidx30, align 4124 %i11 = load i32, ptr %g21, align 4125 %arrayidx37 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 5126 store i32 %i11, ptr %arrayidx37, align 4127 %i13 = load i32, ptr %g22, align 4128 %arrayidx44 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 6129 store i32 %i13, ptr %arrayidx44, align 4130 %i15 = load i32, ptr %g20, align 4131 %arrayidx51 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 7132 store i32 %i15, ptr %arrayidx51, align 4133 ret void134}135 136define dso_local void @test_cost_splits(ptr nocapture %p) local_unnamed_addr {137; CHECK-LABEL: @test_cost_splits(138; CHECK-NEXT: entry:139; CHECK-NEXT: [[P1:%.*]] = alloca [16 x i32], align 16140; CHECK-NEXT: [[P2:%.*]] = alloca [16 x i32], align 16141; CHECK-NEXT: [[P3:%.*]] = alloca [16 x i32], align 16142; CHECK-NEXT: [[P4:%.*]] = alloca [16 x i32], align 16143; CHECK-NEXT: [[G10:%.*]] = getelementptr inbounds [16 x i32], ptr [[P1]], i32 0, i64 4144; CHECK-NEXT: [[G12:%.*]] = getelementptr inbounds [16 x i32], ptr [[P2]], i32 0, i64 6145; CHECK-NEXT: [[G20:%.*]] = getelementptr inbounds [16 x i32], ptr [[P3]], i32 0, i64 12146; CHECK-NEXT: [[G22:%.*]] = getelementptr inbounds [16 x i32], ptr [[P4]], i32 0, i64 14147; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i32>, ptr [[G10]], align 4148; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i32>, ptr [[G12]], align 4149; CHECK-NEXT: [[TMP2:%.*]] = load <2 x i32>, ptr [[G20]], align 4150; CHECK-NEXT: [[TMP3:%.*]] = load <2 x i32>, ptr [[G22]], align 4151; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <2 x i32> [[TMP0]], <2 x i32> poison, <8 x i32> <i32 0, i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>152; CHECK-NEXT: [[TMP5:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> poison, <8 x i32> <i32 0, i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>153; CHECK-NEXT: [[TMP6:%.*]] = shufflevector <2 x i32> [[TMP0]], <2 x i32> [[TMP1]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison>154; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <2 x i32> [[TMP2]], <2 x i32> poison, <8 x i32> <i32 0, i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>155; CHECK-NEXT: [[TMP8:%.*]] = shufflevector <8 x i32> [[TMP6]], <8 x i32> [[TMP10]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 poison, i32 poison>156; CHECK-NEXT: [[TMP9:%.*]] = shufflevector <2 x i32> [[TMP3]], <2 x i32> poison, <8 x i32> <i32 0, i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>157; CHECK-NEXT: [[TMP7:%.*]] = shufflevector <8 x i32> [[TMP8]], <8 x i32> [[TMP9]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 8, i32 9>158; CHECK-NEXT: store <8 x i32> [[TMP7]], ptr [[P:%.*]], align 4159; CHECK-NEXT: ret void160;161entry:162 %p1 = alloca [16 x i32], align 16163 %p2 = alloca [16 x i32], align 16164 %p3 = alloca [16 x i32], align 16165 %p4 = alloca [16 x i32], align 16166 %g10 = getelementptr inbounds [16 x i32], ptr %p1, i32 0, i64 4167 %g11 = getelementptr inbounds [16 x i32], ptr %p1, i32 0, i64 5168 %g12 = getelementptr inbounds [16 x i32], ptr %p2, i32 0, i64 6169 %g13 = getelementptr inbounds [16 x i32], ptr %p2, i32 0, i64 7170 %g20 = getelementptr inbounds [16 x i32], ptr %p3, i32 0, i64 12171 %g21 = getelementptr inbounds [16 x i32], ptr %p3, i32 0, i64 13172 %g22 = getelementptr inbounds [16 x i32], ptr %p4, i32 0, i64 14173 %g23 = getelementptr inbounds [16 x i32], ptr %p4, i32 0, i64 15174 %i1 = load i32, ptr %g10, align 4175 store i32 %i1, ptr %p, align 4176 %i3 = load i32, ptr %g11, align 4177 %arrayidx9 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 1178 store i32 %i3, ptr %arrayidx9, align 4179 %i5 = load i32, ptr %g12, align 4180 %arrayidx16 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 2181 store i32 %i5, ptr %arrayidx16, align 4182 %i7 = load i32, ptr %g13, align 4183 %arrayidx23 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 3184 store i32 %i7, ptr %arrayidx23, align 4185 %i9 = load i32, ptr %g20, align 4186 %arrayidx30 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 4187 store i32 %i9, ptr %arrayidx30, align 4188 %i11 = load i32, ptr %g21, align 4189 %arrayidx37 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 5190 store i32 %i11, ptr %arrayidx37, align 4191 %i13 = load i32, ptr %g22, align 4192 %arrayidx44 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 6193 store i32 %i13, ptr %arrayidx44, align 4194 %i15 = load i32, ptr %g23, align 4195 %arrayidx51 = getelementptr inbounds %struct.S, ptr %p, i64 0, i32 0, i64 7196 store i32 %i15, ptr %arrayidx51, align 4197 ret void198}199