brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.1 KiB · 3376fb8 Raw
223 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -mtriple=aarch64--linux-gnu -passes=slp-vectorizer -slp-threshold=-12 -pass-remarks-output=%t < %s | FileCheck %s3; RUN: cat %t | FileCheck -check-prefix=YAML %s4; RUN: opt -S -mtriple=aarch64--linux-gnu -passes=slp-vectorizer -slp-threshold=-12 -pass-remarks-output=%t < %s | FileCheck %s5; RUN: cat %t | FileCheck -check-prefix=YAML %s6 7; These tests check that we remove from consideration pairs of seed8; getelementptrs when they are known to have a constant difference. Such pairs9; are likely not good candidates for vectorization since one can be computed10; from the other. We use an unprofitable threshold to force vectorization.11;12; int getelementptr(int *g, int n, int w, int x, int y, int z) {13;   int sum = 0;14;   for (int i = 0; i < n ; ++i) {15;     sum += g[2*i + w]; sum += g[2*i + x];16;     sum += g[2*i + y]; sum += g[2*i + z];17;   }18;   return sum;19; }20;21 22; YAML-LABEL: Function:        getelementptr_4x3223; YAML:      --- !Passed24; YAML-NEXT: Pass:            slp-vectorizer25; YAML-NEXT: Name:            VectorizedList26; YAML-NEXT: Function:        getelementptr_4x3227; YAML-NEXT: Args:28; YAML-NEXT:   - String:          'SLP vectorized with cost '29; YAML-NEXT:   - Cost:            '6'30; YAML-NEXT:   - String:          ' and with tree size '31; YAML-NEXT:   - TreeSize:        '3'32 33; YAML:      --- !Passed34; YAML-NEXT: Pass:            slp-vectorizer35; YAML-NEXT: Name:            VectorizedList36; YAML-NEXT: Function:        getelementptr_4x3237; YAML-NEXT: Args:38; YAML-NEXT:   - String:          'SLP vectorized with cost '39; YAML-NEXT:   - Cost:            '8'40; YAML-NEXT:   - String:          ' and with tree size '41; YAML-NEXT:   - TreeSize:        '3'42 43define i32 @getelementptr_4x32(ptr nocapture readonly %g, i32 %n, i32 %x, i32 %y, i32 %z) {44; CHECK-LABEL: @getelementptr_4x32(45; CHECK-NEXT:  entry:46; CHECK-NEXT:    [[CMP31:%.*]] = icmp sgt i32 [[N:%.*]], 047; CHECK-NEXT:    br i1 [[CMP31]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]48; CHECK:       for.body.preheader:49; CHECK-NEXT:    [[TMP0:%.*]] = insertelement <2 x i32> <i32 0, i32 poison>, i32 [[X:%.*]], i32 150; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <2 x i32> poison, i32 [[Y:%.*]], i32 051; CHECK-NEXT:    [[TMP2:%.*]] = insertelement <2 x i32> [[TMP1]], i32 [[Z:%.*]], i32 152; CHECK-NEXT:    br label [[FOR_BODY:%.*]]53; CHECK:       for.cond.cleanup.loopexit:54; CHECK-NEXT:    [[ADD16:%.*]] = extractelement <2 x i32> [[TMP17:%.*]], i32 055; CHECK-NEXT:    br label [[FOR_COND_CLEANUP]]56; CHECK:       for.cond.cleanup:57; CHECK-NEXT:    [[SUM_0_LCSSA:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[ADD16]], [[FOR_COND_CLEANUP_LOOPEXIT:%.*]] ]58; CHECK-NEXT:    ret i32 [[SUM_0_LCSSA]]59; CHECK:       for.body:60; CHECK-NEXT:    [[TMP6:%.*]] = phi <2 x i32> [ zeroinitializer, [[FOR_BODY_PREHEADER]] ], [ [[TMP17]], [[FOR_BODY]] ]61; CHECK-NEXT:    [[TMP15:%.*]] = extractelement <2 x i32> [[TMP6]], i32 162; CHECK-NEXT:    [[T4:%.*]] = shl nsw i32 [[TMP15]], 163; CHECK-NEXT:    [[TMP16:%.*]] = extractelement <2 x i32> [[TMP6]], i32 064; CHECK-NEXT:    [[TMP3:%.*]] = insertelement <2 x i32> poison, i32 [[T4]], i32 065; CHECK-NEXT:    [[TMP4:%.*]] = shufflevector <2 x i32> [[TMP3]], <2 x i32> poison, <2 x i32> zeroinitializer66; CHECK-NEXT:    [[TMP5:%.*]] = add nsw <2 x i32> [[TMP4]], [[TMP0]]67; CHECK-NEXT:    [[TMP12:%.*]] = extractelement <2 x i32> [[TMP5]], i32 068; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[G:%.*]], i32 [[TMP12]]69; CHECK-NEXT:    [[T6:%.*]] = load i32, ptr [[ARRAYIDX]], align 470; CHECK-NEXT:    [[ADD1:%.*]] = add nsw i32 [[T6]], [[TMP16]]71; CHECK-NEXT:    [[TMP11:%.*]] = extractelement <2 x i32> [[TMP5]], i32 172; CHECK-NEXT:    [[ARRAYIDX5:%.*]] = getelementptr inbounds i32, ptr [[G]], i32 [[TMP11]]73; CHECK-NEXT:    [[T8:%.*]] = load i32, ptr [[ARRAYIDX5]], align 474; CHECK-NEXT:    [[ADD6:%.*]] = add nsw i32 [[ADD1]], [[T8]]75; CHECK-NEXT:    [[TMP18:%.*]] = add nsw <2 x i32> [[TMP4]], [[TMP2]]76; CHECK-NEXT:    [[TMP13:%.*]] = extractelement <2 x i32> [[TMP18]], i32 077; CHECK-NEXT:    [[ARRAYIDX10:%.*]] = getelementptr inbounds i32, ptr [[G]], i32 [[TMP13]]78; CHECK-NEXT:    [[T10:%.*]] = load i32, ptr [[ARRAYIDX10]], align 479; CHECK-NEXT:    [[ADD11:%.*]] = add nsw i32 [[ADD6]], [[T10]]80; CHECK-NEXT:    [[TMP14:%.*]] = extractelement <2 x i32> [[TMP18]], i32 181; CHECK-NEXT:    [[ARRAYIDX15:%.*]] = getelementptr inbounds i32, ptr [[G]], i32 [[TMP14]]82; CHECK-NEXT:    [[T12:%.*]] = load i32, ptr [[ARRAYIDX15]], align 483; CHECK-NEXT:    [[TMP19:%.*]] = insertelement <2 x i32> <i32 poison, i32 1>, i32 [[ADD11]], i32 084; CHECK-NEXT:    [[TMP20:%.*]] = insertelement <2 x i32> [[TMP6]], i32 [[T12]], i32 085; CHECK-NEXT:    [[TMP17]] = add nsw <2 x i32> [[TMP19]], [[TMP20]]86; CHECK-NEXT:    [[INDVARS_IV_NEXT:%.*]] = extractelement <2 x i32> [[TMP17]], i32 187; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INDVARS_IV_NEXT]], [[N]]88; CHECK-NEXT:    br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP_LOOPEXIT]], label [[FOR_BODY]]89;90entry:91  %cmp31 = icmp sgt i32 %n, 092  br i1 %cmp31, label %for.body.preheader, label %for.cond.cleanup93 94for.body.preheader:95  br label %for.body96 97for.cond.cleanup.loopexit:98  br label %for.cond.cleanup99 100for.cond.cleanup:101  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add16, %for.cond.cleanup.loopexit ]102  ret i32 %sum.0.lcssa103 104for.body:105  %indvars.iv = phi i32 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]106  %sum.032 = phi i32 [ 0, %for.body.preheader ], [ %add16, %for.body ]107  %t4 = shl nsw i32 %indvars.iv, 1108  %t5 = add nsw i32 %t4, 0109  %arrayidx = getelementptr inbounds i32, ptr %g, i32 %t5110  %t6 = load i32, ptr %arrayidx, align 4111  %add1 = add nsw i32 %t6, %sum.032112  %t7 = add nsw i32 %t4, %x113  %arrayidx5 = getelementptr inbounds i32, ptr %g, i32 %t7114  %t8 = load i32, ptr %arrayidx5, align 4115  %add6 = add nsw i32 %add1, %t8116  %t9 = add nsw i32 %t4, %y117  %arrayidx10 = getelementptr inbounds i32, ptr %g, i32 %t9118  %t10 = load i32, ptr %arrayidx10, align 4119  %add11 = add nsw i32 %add6, %t10120  %t11 = add nsw i32 %t4, %z121  %arrayidx15 = getelementptr inbounds i32, ptr %g, i32 %t11122  %t12 = load i32, ptr %arrayidx15, align 4123  %add16 = add nsw i32 %add11, %t12124  %indvars.iv.next = add nuw nsw i32 %indvars.iv, 1125  %exitcond = icmp eq i32 %indvars.iv.next , %n126  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body127}128 129; YAML-LABEL: Function:        getelementptr_2x32130; YAML:      --- !Passed131; YAML:      Pass:            slp-vectorizer132; YAML:      Name:            VectorizedList133; YAML:      Function:        getelementptr_2x32134; YAML:     Args:135; YAML:        - String:          'SLP vectorized with cost '136; YAML:        - Cost:            '8'137; YAML-NEXT:   - String:          ' and with tree size '138; YAML-NEXT:   - TreeSize:        '3'139 140define i32 @getelementptr_2x32(ptr nocapture readonly %g, i32 %n, i32 %x, i32 %y, i32 %z) {141; CHECK-LABEL: @getelementptr_2x32(142; CHECK-NEXT:  entry:143; CHECK-NEXT:    [[CMP31:%.*]] = icmp sgt i32 [[N:%.*]], 0144; CHECK-NEXT:    br i1 [[CMP31]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]145; CHECK:       for.body.preheader:146; CHECK-NEXT:    [[TMP4:%.*]] = insertelement <2 x i32> poison, i32 [[Y:%.*]], i32 0147; CHECK-NEXT:    [[TMP0:%.*]] = insertelement <2 x i32> [[TMP4]], i32 [[Z:%.*]], i32 1148; CHECK-NEXT:    br label [[FOR_BODY:%.*]]149; CHECK:       for.cond.cleanup.loopexit:150; CHECK-NEXT:    [[OP_RDX:%.*]] = extractelement <2 x i32> [[TMP13:%.*]], i32 0151; CHECK-NEXT:    br label [[FOR_COND_CLEANUP]]152; CHECK:       for.cond.cleanup:153; CHECK-NEXT:    [[SUM_0_LCSSA:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[OP_RDX]], [[FOR_COND_CLEANUP_LOOPEXIT:%.*]] ]154; CHECK-NEXT:    ret i32 [[SUM_0_LCSSA]]155; CHECK:       for.body:156; CHECK-NEXT:    [[TMP6:%.*]] = phi <2 x i32> [ zeroinitializer, [[FOR_BODY_PREHEADER]] ], [ [[TMP13]], [[FOR_BODY]] ]157; CHECK-NEXT:    [[TMP12:%.*]] = extractelement <2 x i32> [[TMP6]], i32 1158; CHECK-NEXT:    [[T4:%.*]] = shl nsw i32 [[TMP12]], 1159; CHECK-NEXT:    [[T5:%.*]] = add nsw i32 [[T4]], 0160; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[G:%.*]], i32 [[T5]]161; CHECK-NEXT:    [[T6:%.*]] = load i32, ptr [[ARRAYIDX]], align 4162; CHECK-NEXT:    [[TMP5:%.*]] = extractelement <2 x i32> [[TMP6]], i32 0163; CHECK-NEXT:    [[ADD1:%.*]] = add nsw i32 [[T6]], [[TMP5]]164; CHECK-NEXT:    [[T7:%.*]] = add nsw i32 [[T4]], 1165; CHECK-NEXT:    [[ARRAYIDX5:%.*]] = getelementptr inbounds i32, ptr [[G]], i32 [[T7]]166; CHECK-NEXT:    [[T8:%.*]] = load i32, ptr [[ARRAYIDX5]], align 4167; CHECK-NEXT:    [[ADD6:%.*]] = add nsw i32 [[ADD1]], [[T8]]168; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <2 x i32> poison, i32 [[T4]], i32 0169; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> poison, <2 x i32> zeroinitializer170; CHECK-NEXT:    [[TMP3:%.*]] = add nsw <2 x i32> [[TMP2]], [[TMP0]]171; CHECK-NEXT:    [[TMP9:%.*]] = extractelement <2 x i32> [[TMP3]], i32 0172; CHECK-NEXT:    [[ARRAYIDX11:%.*]] = getelementptr inbounds i32, ptr [[G]], i32 [[TMP9]]173; CHECK-NEXT:    [[T10:%.*]] = load i32, ptr [[ARRAYIDX11]], align 4174; CHECK-NEXT:    [[ADD11:%.*]] = add nsw i32 [[ADD6]], [[T10]]175; CHECK-NEXT:    [[TMP10:%.*]] = extractelement <2 x i32> [[TMP3]], i32 1176; CHECK-NEXT:    [[ARRAYIDX15:%.*]] = getelementptr inbounds i32, ptr [[G]], i32 [[TMP10]]177; CHECK-NEXT:    [[T12:%.*]] = load i32, ptr [[ARRAYIDX15]], align 4178; CHECK-NEXT:    [[TMP11:%.*]] = insertelement <2 x i32> <i32 poison, i32 1>, i32 [[ADD11]], i32 0179; CHECK-NEXT:    [[TMP14:%.*]] = insertelement <2 x i32> [[TMP6]], i32 [[T12]], i32 0180; CHECK-NEXT:    [[TMP13]] = add nsw <2 x i32> [[TMP11]], [[TMP14]]181; CHECK-NEXT:    [[INDVARS_IV_NEXT:%.*]] = extractelement <2 x i32> [[TMP13]], i32 1182; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INDVARS_IV_NEXT]], [[N]]183; CHECK-NEXT:    br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP_LOOPEXIT]], label [[FOR_BODY]]184;185entry:186  %cmp31 = icmp sgt i32 %n, 0187  br i1 %cmp31, label %for.body.preheader, label %for.cond.cleanup188 189for.body.preheader:190  br label %for.body191 192for.cond.cleanup.loopexit:193  br label %for.cond.cleanup194 195for.cond.cleanup:196  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add16, %for.cond.cleanup.loopexit ]197  ret i32 %sum.0.lcssa198 199for.body:200  %indvars.iv = phi i32 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]201  %sum.032 = phi i32 [ 0, %for.body.preheader ], [ %add16, %for.body ]202  %t4 = shl nsw i32 %indvars.iv, 1203  %t5 = add nsw i32 %t4, 0204  %arrayidx = getelementptr inbounds i32, ptr %g, i32 %t5205  %t6 = load i32, ptr %arrayidx, align 4206  %add1 = add nsw i32 %t6, %sum.032207  %t7 = add nsw i32 %t4, 1208  %arrayidx5 = getelementptr inbounds i32, ptr %g, i32 %t7209  %t8 = load i32, ptr %arrayidx5, align 4210  %add6 = add nsw i32 %add1, %t8211  %t9 = add nsw i32 %t4, %y212  %arrayidx10 = getelementptr inbounds i32, ptr %g, i32 %t9213  %t10 = load i32, ptr %arrayidx10, align 4214  %add11 = add nsw i32 %add6, %t10215  %t11 = add nsw i32 %t4, %z216  %arrayidx15 = getelementptr inbounds i32, ptr %g, i32 %t11217  %t12 = load i32, ptr %arrayidx15, align 4218  %add16 = add nsw i32 %add11, %t12219  %indvars.iv.next = add nuw nsw i32 %indvars.iv, 1220  %exitcond = icmp eq i32 %indvars.iv.next , %n221  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body222}223