brintos

brintos / llvm-project-archived public Read only

0
0
Text · 25.0 KiB · 5cc228f Raw
467 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 52; RUN: opt < %s -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=8 -S | FileCheck %s3 4; int int_inc;5;6;void induction_with_global(int init, int *restrict A, int N) {7;  int x = init;8;  for (int i=0;i<N;i++){9;    A[i] = x;10;    x += int_inc;11;  }12;}13 14 15target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"16 17 18@int_inc = common global i32 0, align 419 20define void @induction_with_global(i32 %init, ptr noalias nocapture %A, i32 %N) {21; CHECK-LABEL: define void @induction_with_global(22; CHECK-SAME: i32 [[INIT:%.*]], ptr noalias captures(none) [[A:%.*]], i32 [[N:%.*]]) {23; CHECK-NEXT:  [[ENTRY:.*]]:24; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr @int_inc, align 425; CHECK-NEXT:    [[TMP1:%.*]] = add i32 [[N]], -126; CHECK-NEXT:    [[TMP5:%.*]] = zext i32 [[TMP1]] to i6427; CHECK-NEXT:    [[TMP2:%.*]] = add nuw nsw i64 [[TMP5]], 128; CHECK-NEXT:    [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP2]], 829; CHECK-NEXT:    br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]30; CHECK:       [[VECTOR_PH]]:31; CHECK-NEXT:    [[N_MOD_VF:%.*]] = urem i64 [[TMP2]], 832; CHECK-NEXT:    [[N_VEC:%.*]] = sub i64 [[TMP2]], [[N_MOD_VF]]33; CHECK-NEXT:    [[DOTCAST:%.*]] = trunc i64 [[N_VEC]] to i3234; CHECK-NEXT:    [[TMP3:%.*]] = mul i32 [[DOTCAST]], [[TMP0]]35; CHECK-NEXT:    [[TMP4:%.*]] = add i32 [[INIT]], [[TMP3]]36; CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x i32> poison, i32 [[INIT]], i64 037; CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x i32> [[DOTSPLATINSERT]], <8 x i32> poison, <8 x i32> zeroinitializer38; CHECK-NEXT:    [[DOTSPLATINSERT2:%.*]] = insertelement <8 x i32> poison, i32 [[TMP0]], i64 039; CHECK-NEXT:    [[DOTSPLAT3:%.*]] = shufflevector <8 x i32> [[DOTSPLATINSERT2]], <8 x i32> poison, <8 x i32> zeroinitializer40; CHECK-NEXT:    [[TMP6:%.*]] = mul nsw <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>, [[DOTSPLAT3]]41; CHECK-NEXT:    [[INDUCTION:%.*]] = add nsw <8 x i32> [[DOTSPLAT]], [[TMP6]]42; CHECK-NEXT:    [[TMP7:%.*]] = mul nsw i32 [[TMP0]], 843; CHECK-NEXT:    [[DOTSPLATINSERT5:%.*]] = insertelement <8 x i32> poison, i32 [[TMP7]], i64 044; CHECK-NEXT:    [[DOTSPLAT6:%.*]] = shufflevector <8 x i32> [[DOTSPLATINSERT5]], <8 x i32> poison, <8 x i32> zeroinitializer45; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]46; CHECK:       [[VECTOR_BODY]]:47; CHECK-NEXT:    [[TMP8:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]48; CHECK-NEXT:    [[VEC_IND:%.*]] = phi <8 x i32> [ [[INDUCTION]], %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[VECTOR_BODY]] ]49; CHECK-NEXT:    [[TMP9:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[TMP8]]50; CHECK-NEXT:    store <8 x i32> [[VEC_IND]], ptr [[TMP9]], align 451; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[TMP8]], 852; CHECK-NEXT:    [[VEC_IND_NEXT]] = add nsw <8 x i32> [[VEC_IND]], [[DOTSPLAT6]]53; CHECK-NEXT:    [[TMP12:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]54; CHECK-NEXT:    br i1 [[TMP12]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]55; CHECK:       [[MIDDLE_BLOCK]]:56; CHECK-NEXT:    [[CMP_N:%.*]] = icmp eq i64 [[TMP2]], [[N_VEC]]57; CHECK-NEXT:    br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]58; CHECK:       [[SCALAR_PH]]:59; CHECK-NEXT:    [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]60; CHECK-NEXT:    [[BC_RESUME_VAL5:%.*]] = phi i32 [ [[TMP4]], %[[MIDDLE_BLOCK]] ], [ [[INIT]], %[[ENTRY]] ]61; CHECK-NEXT:    br label %[[FOR_BODY:.*]]62; CHECK:       [[FOR_BODY]]:63; CHECK-NEXT:    [[INDVARS_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], %[[FOR_BODY]] ]64; CHECK-NEXT:    [[X_05:%.*]] = phi i32 [ [[BC_RESUME_VAL5]], %[[SCALAR_PH]] ], [ [[ADD:%.*]], %[[FOR_BODY]] ]65; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]66; CHECK-NEXT:    store i32 [[X_05]], ptr [[ARRAYIDX]], align 467; CHECK-NEXT:    [[ADD]] = add nsw i32 [[TMP0]], [[X_05]]68; CHECK-NEXT:    [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 169; CHECK-NEXT:    [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i3270; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[LFTR_WIDEIV]], [[N]]71; CHECK-NEXT:    br i1 [[EXITCOND]], label %[[EXIT]], label %[[FOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]]72; CHECK:       [[EXIT]]:73; CHECK-NEXT:    ret void74;75entry:76  %0 = load i32, ptr @int_inc, align 477  br label %for.body78 79for.body:                                         ; preds = %for.body, %entry80  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]81  %x.05 = phi i32 [ %init, %entry ], [ %add, %for.body ]82  %arrayidx = getelementptr inbounds i32, ptr %A, i64 %iv83  store i32 %x.05, ptr %arrayidx, align 484  %add = add nsw i32 %0, %x.0585  %iv.next = add nuw nsw i64 %iv, 186  %iv.next.trunc = trunc i64 %iv.next to i3287  %exitcond = icmp eq i32 %iv.next.trunc, %N88  br i1 %exitcond, label %exit, label %for.body89 90exit:91  ret void92}93 94;int induction_with_loop_inv(int init, int *restrict A, int N, int M) {95;  int x = init;96;  for (int j = 0; j < M; j++) {97;    for (int i=0; i<N; i++){98;      A[i] = x;99;      x += j; // induction step is a loop invariant variable100;    }101;  }102;  return x;103;}104 105define i32 @induction_with_loop_inv(i32 %init, ptr noalias nocapture %A, i32 %N, i32 %M) {106; CHECK-LABEL: define i32 @induction_with_loop_inv(107; CHECK-SAME: i32 [[INIT:%.*]], ptr noalias captures(none) [[A:%.*]], i32 [[N:%.*]], i32 [[M:%.*]]) {108; CHECK-NEXT:  [[ENTRY:.*]]:109; CHECK-NEXT:    [[TMP3:%.*]] = add i32 [[N]], -1110; CHECK-NEXT:    [[TMP11:%.*]] = zext i32 [[TMP3]] to i64111; CHECK-NEXT:    [[TMP0:%.*]] = add nuw nsw i64 [[TMP11]], 1112; CHECK-NEXT:    br label %[[OUTER_HEADER:.*]]113; CHECK:       [[OUTER_HEADER]]:114; CHECK-NEXT:    [[INDVARS_IV15:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[INDVARS_IV_NEXT16:%.*]], %[[OUTER_LATCH:.*]] ]115; CHECK-NEXT:    [[J_012:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[INC5:%.*]], %[[OUTER_LATCH]] ]116; CHECK-NEXT:    [[X_011:%.*]] = phi i32 [ [[INIT]], %[[ENTRY]] ], [ [[X_0_LCSSA:%.*]], %[[OUTER_LATCH]] ]117; CHECK-NEXT:    [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP0]], 8118; CHECK-NEXT:    br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]119; CHECK:       [[VECTOR_PH]]:120; CHECK-NEXT:    [[N_MOD_VF:%.*]] = urem i64 [[TMP0]], 8121; CHECK-NEXT:    [[N_VEC:%.*]] = sub i64 [[TMP0]], [[N_MOD_VF]]122; CHECK-NEXT:    [[DOTCAST:%.*]] = trunc i64 [[N_VEC]] to i32123; CHECK-NEXT:    [[TMP1:%.*]] = mul i32 [[DOTCAST]], [[J_012]]124; CHECK-NEXT:    [[TMP2:%.*]] = add i32 [[X_011]], [[TMP1]]125; CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x i32> poison, i32 [[X_011]], i64 0126; CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x i32> [[DOTSPLATINSERT]], <8 x i32> poison, <8 x i32> zeroinitializer127; CHECK-NEXT:    [[DOTSPLATINSERT2:%.*]] = insertelement <8 x i32> poison, i32 [[J_012]], i64 0128; CHECK-NEXT:    [[DOTSPLAT3:%.*]] = shufflevector <8 x i32> [[DOTSPLATINSERT2]], <8 x i32> poison, <8 x i32> zeroinitializer129; CHECK-NEXT:    [[TMP8:%.*]] = mul nsw <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>, [[DOTSPLAT3]]130; CHECK-NEXT:    [[INDUCTION:%.*]] = add nsw <8 x i32> [[DOTSPLAT]], [[TMP8]]131; CHECK-NEXT:    [[TMP5:%.*]] = mul nsw i32 [[J_012]], 8132; CHECK-NEXT:    [[DOTSPLATINSERT5:%.*]] = insertelement <8 x i32> poison, i32 [[TMP5]], i64 0133; CHECK-NEXT:    [[DOTSPLAT6:%.*]] = shufflevector <8 x i32> [[DOTSPLATINSERT5]], <8 x i32> poison, <8 x i32> zeroinitializer134; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]135; CHECK:       [[VECTOR_BODY]]:136; CHECK-NEXT:    [[TMP6:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]137; CHECK-NEXT:    [[VEC_IND:%.*]] = phi <8 x i32> [ [[INDUCTION]], %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[VECTOR_BODY]] ]138; CHECK-NEXT:    [[TMP7:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[TMP6]]139; CHECK-NEXT:    store <8 x i32> [[VEC_IND]], ptr [[TMP7]], align 4140; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[TMP6]], 8141; CHECK-NEXT:    [[VEC_IND_NEXT]] = add nsw <8 x i32> [[VEC_IND]], [[DOTSPLAT6]]142; CHECK-NEXT:    [[TMP10:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]143; CHECK-NEXT:    br i1 [[TMP10]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]144; CHECK:       [[MIDDLE_BLOCK]]:145; CHECK-NEXT:    [[CMP_N:%.*]] = icmp eq i64 [[TMP0]], [[N_VEC]]146; CHECK-NEXT:    br i1 [[CMP_N]], label %[[INNER_EXIT:.*]], label %[[SCALAR_PH]]147; CHECK:       [[SCALAR_PH]]:148; CHECK-NEXT:    [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[OUTER_HEADER]] ]149; CHECK-NEXT:    [[BC_RESUME_VAL5:%.*]] = phi i32 [ [[TMP2]], %[[MIDDLE_BLOCK]] ], [ [[X_011]], %[[OUTER_HEADER]] ]150; CHECK-NEXT:    br label %[[INNER:.*]]151; CHECK:       [[INNER]]:152; CHECK-NEXT:    [[INDVARS_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], %[[INNER]] ]153; CHECK-NEXT:    [[X_18:%.*]] = phi i32 [ [[BC_RESUME_VAL5]], %[[SCALAR_PH]] ], [ [[ADD:%.*]], %[[INNER]] ]154; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]155; CHECK-NEXT:    store i32 [[X_18]], ptr [[ARRAYIDX]], align 4156; CHECK-NEXT:    [[ADD]] = add nsw i32 [[X_18]], [[J_012]]157; CHECK-NEXT:    [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1158; CHECK-NEXT:    [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32159; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[LFTR_WIDEIV]], [[N]]160; CHECK-NEXT:    br i1 [[EXITCOND]], label %[[INNER_EXIT]], label %[[INNER]], !llvm.loop [[LOOP5:![0-9]+]]161; CHECK:       [[INNER_EXIT]]:162; CHECK-NEXT:    [[TMP9:%.*]] = add i32 [[X_011]], [[INDVARS_IV15]]163; CHECK-NEXT:    br label %[[OUTER_LATCH]]164; CHECK:       [[OUTER_LATCH]]:165; CHECK-NEXT:    [[X_0_LCSSA]] = phi i32 [ [[TMP9]], %[[INNER_EXIT]] ]166; CHECK-NEXT:    [[INC5]] = add nuw nsw i32 [[J_012]], 1167; CHECK-NEXT:    [[INDVARS_IV_NEXT16]] = add i32 [[INDVARS_IV15]], [[N]]168; CHECK-NEXT:    [[EXITCOND17:%.*]] = icmp eq i32 [[INC5]], [[M]]169; CHECK-NEXT:    br i1 [[EXITCOND17]], label %[[EXIT:.*]], label %[[OUTER_HEADER]]170; CHECK:       [[EXIT]]:171; CHECK-NEXT:    ret i32 [[X_0_LCSSA]]172;173entry:174  br label %outer.header175 176outer.header:177  %outer.iv = phi i32 [ 0, %entry ], [ %outer.iv.next, %outer.latch ]178  %j.012 = phi i32 [ 0, %entry ], [ %inc5, %outer.latch ]179  %x.011 = phi i32 [ %init, %entry ], [ %x.1.lcssa, %outer.latch ]180  br label %inner181 182inner:183  %iv = phi i64 [ 0, %outer.header ], [ %iv.next, %inner ]184  %x.18 = phi i32 [ %x.011, %outer.header ], [ %add, %inner ]185  %arrayidx = getelementptr inbounds i32, ptr %A, i64 %iv186  store i32 %x.18, ptr %arrayidx, align 4187  %add = add nsw i32 %x.18, %j.012188  %iv.next = add nuw nsw i64 %iv, 1189  %iv.next.trunc = trunc i64 %iv.next to i32190  %inner.ec = icmp eq i32 %iv.next.trunc, %N191  br i1 %inner.ec, label %inner.exit, label %inner192 193inner.exit:194  %add.ivs  = add i32 %x.011, %outer.iv195  br label %outer.latch196 197outer.latch:198  %x.1.lcssa = phi i32 [ %add.ivs, %inner.exit ]199  %inc5 = add nuw nsw i32 %j.012, 1200  %outer.iv.next = add i32 %outer.iv, %N201  %outer.ec = icmp eq i32 %inc5, %M202  br i1 %outer.ec, label %exit, label %outer.header203 204exit:205  ret i32 %x.1.lcssa206}207 208define void @non_primary_iv_loop_inv_trunc(ptr %a, i64 %n, i64 %step) {209; CHECK-LABEL: define void @non_primary_iv_loop_inv_trunc(210; CHECK-SAME: ptr [[A:%.*]], i64 [[N:%.*]], i64 [[STEP:%.*]]) {211; CHECK-NEXT:  [[ENTRY:.*]]:212; CHECK-NEXT:    [[SMAX:%.*]] = call i64 @llvm.smax.i64(i64 [[N]], i64 1)213; CHECK-NEXT:    [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[SMAX]], 8214; CHECK-NEXT:    br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]215; CHECK:       [[VECTOR_PH]]:216; CHECK-NEXT:    [[N_MOD_VF:%.*]] = urem i64 [[SMAX]], 8217; CHECK-NEXT:    [[N_VEC:%.*]] = sub i64 [[SMAX]], [[N_MOD_VF]]218; CHECK-NEXT:    [[TMP0:%.*]] = mul i64 [[N_VEC]], [[STEP]]219; CHECK-NEXT:    [[TMP3:%.*]] = trunc i64 [[STEP]] to i32220; CHECK-NEXT:    [[DOTSPLATINSERT5:%.*]] = insertelement <8 x i32> poison, i32 [[TMP3]], i64 0221; CHECK-NEXT:    [[DOTSPLAT6:%.*]] = shufflevector <8 x i32> [[DOTSPLATINSERT5]], <8 x i32> poison, <8 x i32> zeroinitializer222; CHECK-NEXT:    [[TMP2:%.*]] = mul <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>, [[DOTSPLAT6]]223; CHECK-NEXT:    [[INDUCTION:%.*]] = add <8 x i32> zeroinitializer, [[TMP2]]224; CHECK-NEXT:    [[TMP5:%.*]] = mul i32 [[TMP3]], 8225; CHECK-NEXT:    [[DOTSPLATINSERT8:%.*]] = insertelement <8 x i32> poison, i32 [[TMP5]], i64 0226; CHECK-NEXT:    [[DOTSPLAT9:%.*]] = shufflevector <8 x i32> [[DOTSPLATINSERT8]], <8 x i32> poison, <8 x i32> zeroinitializer227; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]228; CHECK:       [[VECTOR_BODY]]:229; CHECK-NEXT:    [[TMP6:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]230; CHECK-NEXT:    [[VEC_IND10:%.*]] = phi <8 x i32> [ [[INDUCTION]], %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[VECTOR_BODY]] ]231; CHECK-NEXT:    [[TMP7:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[TMP6]]232; CHECK-NEXT:    store <8 x i32> [[VEC_IND10]], ptr [[TMP7]], align 4233; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[TMP6]], 8234; CHECK-NEXT:    [[VEC_IND_NEXT]] = add <8 x i32> [[VEC_IND10]], [[DOTSPLAT9]]235; CHECK-NEXT:    [[TMP9:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]236; CHECK-NEXT:    br i1 [[TMP9]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]]237; CHECK:       [[MIDDLE_BLOCK]]:238; CHECK-NEXT:    [[CMP_N:%.*]] = icmp eq i64 [[SMAX]], [[N_VEC]]239; CHECK-NEXT:    br i1 [[CMP_N]], label %[[FOR_END:.*]], label %[[SCALAR_PH]]240; CHECK:       [[SCALAR_PH]]:241; CHECK-NEXT:    [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]242; CHECK-NEXT:    [[BC_RESUME_VAL3:%.*]] = phi i64 [ [[TMP0]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]243; CHECK-NEXT:    br label %[[FOR_BODY:.*]]244; CHECK:       [[FOR_BODY]]:245; CHECK-NEXT:    [[I:%.*]] = phi i64 [ [[I_NEXT:%.*]], %[[FOR_BODY]] ], [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ]246; CHECK-NEXT:    [[J:%.*]] = phi i64 [ [[J_NEXT:%.*]], %[[FOR_BODY]] ], [ [[BC_RESUME_VAL3]], %[[SCALAR_PH]] ]247; CHECK-NEXT:    [[TMP0:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[I]]248; CHECK-NEXT:    [[TMP3:%.*]] = trunc i64 [[J]] to i32249; CHECK-NEXT:    store i32 [[TMP3]], ptr [[TMP0]], align 4250; CHECK-NEXT:    [[I_NEXT]] = add nuw nsw i64 [[I]], 1251; CHECK-NEXT:    [[J_NEXT]] = add nuw nsw i64 [[J]], [[STEP]]252; CHECK-NEXT:    [[COND:%.*]] = icmp slt i64 [[I_NEXT]], [[N]]253; CHECK-NEXT:    br i1 [[COND]], label %[[FOR_BODY]], label %[[FOR_END]], !llvm.loop [[LOOP7:![0-9]+]]254; CHECK:       [[FOR_END]]:255; CHECK-NEXT:    ret void256;257entry:258  br label %for.body259 260for.body:261  %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ]262  %j = phi i64 [ %j.next, %for.body ], [ 0, %entry ]263  %tmp0 = getelementptr inbounds i32, ptr %a, i64 %i264  %tmp1 = trunc i64 %j to i32265  store i32 %tmp1, ptr %tmp0, align 4266  %i.next = add nuw nsw i64 %i, 1267  %j.next = add nuw nsw i64 %j, %step268  %cond = icmp slt i64 %i.next, %n269  br i1 %cond, label %for.body, label %for.end270 271for.end:272  ret void273}274 275 276define void @iv_no_binary_op_in_descriptor(i1 %c, ptr %dst) {277; CHECK-LABEL: define void @iv_no_binary_op_in_descriptor(278; CHECK-SAME: i1 [[C:%.*]], ptr [[DST:%.*]]) {279; CHECK-NEXT:  [[ENTRY:.*:]]280; CHECK-NEXT:    br label %[[VECTOR_PH:.*]]281; CHECK:       [[VECTOR_PH]]:282; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]283; CHECK:       [[VECTOR_BODY]]:284; CHECK-NEXT:    [[TMP0:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]285; CHECK-NEXT:    [[VEC_IND:%.*]] = phi <8 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7>, %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[VECTOR_BODY]] ]286; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr inbounds i64, ptr [[DST]], i64 [[TMP0]]287; CHECK-NEXT:    store <8 x i64> [[VEC_IND]], ptr [[TMP1]], align 8288; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[TMP0]], 8289; CHECK-NEXT:    [[VEC_IND_NEXT]] = add <8 x i64> [[VEC_IND]], splat (i64 8)290; CHECK-NEXT:    [[TMP3:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1000291; CHECK-NEXT:    br i1 [[TMP3]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP8:![0-9]+]]292; CHECK:       [[MIDDLE_BLOCK]]:293; CHECK-NEXT:    br label %[[EXIT:.*]]294; CHECK:       [[EXIT]]:295; CHECK-NEXT:    ret void296;297entry:298  br label %loop.header299 300loop.header:301  %iv = phi i64 [ 0, %entry ], [ %iv.next.p, %loop.latch ]302  %gep = getelementptr inbounds i64, ptr %dst, i64 %iv303  store i64 %iv, ptr %gep, align 8304  %iv.next = add i64 %iv, 1305  br label %loop.latch306 307loop.latch:308  %iv.next.p = phi i64 [ %iv.next, %loop.header ]309  %exitcond.not = icmp eq i64 %iv.next.p, 1000310  br i1 %exitcond.not, label %exit, label %loop.header311 312exit:313  ret void314}315 316define void @wide_add_induction_step_live_in(ptr %dst, i64 %N, i16 %off) {317; CHECK-LABEL: define void @wide_add_induction_step_live_in(318; CHECK-SAME: ptr [[DST:%.*]], i64 [[N:%.*]], i16 [[OFF:%.*]]) {319; CHECK-NEXT:  [[ENTRY:.*]]:320; CHECK-NEXT:    [[O_1:%.*]] = add i16 [[OFF]], 2321; CHECK-NEXT:    [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[N]], 8322; CHECK-NEXT:    br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]323; CHECK:       [[VECTOR_PH]]:324; CHECK-NEXT:    [[N_MOD_VF:%.*]] = urem i64 [[N]], 8325; CHECK-NEXT:    [[N_VEC:%.*]] = sub i64 [[N]], [[N_MOD_VF]]326; CHECK-NEXT:    [[DOTCAST:%.*]] = trunc i64 [[N_VEC]] to i16327; CHECK-NEXT:    [[TMP0:%.*]] = mul i16 [[DOTCAST]], [[O_1]]328; CHECK-NEXT:    [[DOTSPLATINSERT1:%.*]] = insertelement <8 x i16> poison, i16 [[O_1]], i64 0329; CHECK-NEXT:    [[DOTSPLAT1:%.*]] = shufflevector <8 x i16> [[DOTSPLATINSERT1]], <8 x i16> poison, <8 x i32> zeroinitializer330; CHECK-NEXT:    [[TMP1:%.*]] = mul <8 x i16> <i16 0, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7>, [[DOTSPLAT1]]331; CHECK-NEXT:    [[INDUCTION:%.*]] = add <8 x i16> zeroinitializer, [[TMP1]]332; CHECK-NEXT:    [[TMP2:%.*]] = mul i16 [[O_1]], 8333; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <8 x i16> poison, i16 [[TMP2]], i64 0334; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <8 x i16> [[BROADCAST_SPLATINSERT]], <8 x i16> poison, <8 x i32> zeroinitializer335; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]336; CHECK:       [[VECTOR_BODY]]:337; CHECK-NEXT:    [[TMP3:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]338; CHECK-NEXT:    [[VEC_IND:%.*]] = phi <8 x i16> [ [[INDUCTION]], %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[VECTOR_BODY]] ]339; CHECK-NEXT:    [[TMP4:%.*]] = add <8 x i16> [[VEC_IND]], [[DOTSPLAT1]]340; CHECK-NEXT:    [[TMP5:%.*]] = getelementptr inbounds i16, ptr [[DST]], i64 [[TMP3]]341; CHECK-NEXT:    store <8 x i16> [[TMP4]], ptr [[TMP5]], align 2342; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[TMP3]], 8343; CHECK-NEXT:    [[VEC_IND_NEXT]] = add <8 x i16> [[VEC_IND]], [[BROADCAST_SPLAT]]344; CHECK-NEXT:    [[TMP7:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]345; CHECK-NEXT:    br i1 [[TMP7]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP9:![0-9]+]]346; CHECK:       [[MIDDLE_BLOCK]]:347; CHECK-NEXT:    [[CMP_N:%.*]] = icmp eq i64 [[N]], [[N_VEC]]348; CHECK-NEXT:    br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]349; CHECK:       [[SCALAR_PH]]:350; CHECK-NEXT:    [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]351; CHECK-NEXT:    [[BC_RESUME_VAL3:%.*]] = phi i16 [ [[TMP0]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]352; CHECK-NEXT:    br label %[[LOOP:.*]]353; CHECK:       [[LOOP]]:354; CHECK-NEXT:    [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]355; CHECK-NEXT:    [[IV_2:%.*]] = phi i16 [ [[BC_RESUME_VAL3]], %[[SCALAR_PH]] ], [ [[ADD:%.*]], %[[LOOP]] ]356; CHECK-NEXT:    [[ADD]] = add i16 [[IV_2]], [[O_1]]357; CHECK-NEXT:    [[GEP_DST:%.*]] = getelementptr inbounds i16, ptr [[DST]], i64 [[IV]]358; CHECK-NEXT:    store i16 [[ADD]], ptr [[GEP_DST]], align 2359; CHECK-NEXT:    [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1360; CHECK-NEXT:    [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]361; CHECK-NEXT:    br i1 [[EC]], label %[[EXIT]], label %[[LOOP]], !llvm.loop [[LOOP10:![0-9]+]]362; CHECK:       [[EXIT]]:363; CHECK-NEXT:    ret void364;365entry:366  %o.1 = add i16 %off, 2367  br label %loop368 369loop:370  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]371  %iv.2 = phi i16 [ 0, %entry ], [ %add, %loop ]372  %add = add i16 %iv.2, %o.1373  %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv374  store i16 %add, ptr %gep.dst, align 2375  %iv.next = add nuw nsw i64 %iv, 1376  %ec = icmp eq i64 %iv.next, %N377  br i1 %ec , label %exit, label %loop378 379exit:380  ret void381}382 383define void @wide_sub_induction_step_live_in(ptr %dst, i64 %N, i16 %off) {384; CHECK-LABEL: define void @wide_sub_induction_step_live_in(385; CHECK-SAME: ptr [[DST:%.*]], i64 [[N:%.*]], i16 [[OFF:%.*]]) {386; CHECK-NEXT:  [[ENTRY:.*]]:387; CHECK-NEXT:    [[O_1:%.*]] = add i16 [[OFF]], 2388; CHECK-NEXT:    [[TMP0:%.*]] = sub i16 -2, [[OFF]]389; CHECK-NEXT:    [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[N]], 8390; CHECK-NEXT:    br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]391; CHECK:       [[VECTOR_PH]]:392; CHECK-NEXT:    [[N_MOD_VF:%.*]] = urem i64 [[N]], 8393; CHECK-NEXT:    [[N_VEC:%.*]] = sub i64 [[N]], [[N_MOD_VF]]394; CHECK-NEXT:    [[DOTCAST:%.*]] = trunc i64 [[N_VEC]] to i16395; CHECK-NEXT:    [[TMP1:%.*]] = mul i16 [[DOTCAST]], [[TMP0]]396; CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x i16> poison, i16 [[O_1]], i64 0397; CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x i16> [[DOTSPLATINSERT]], <8 x i16> poison, <8 x i32> zeroinitializer398; CHECK-NEXT:    [[DOTSPLATINSERT1:%.*]] = insertelement <8 x i16> poison, i16 [[TMP0]], i64 0399; CHECK-NEXT:    [[DOTSPLAT1:%.*]] = shufflevector <8 x i16> [[DOTSPLATINSERT1]], <8 x i16> poison, <8 x i32> zeroinitializer400; CHECK-NEXT:    [[TMP2:%.*]] = mul <8 x i16> <i16 0, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7>, [[DOTSPLAT1]]401; CHECK-NEXT:    [[INDUCTION:%.*]] = add <8 x i16> zeroinitializer, [[TMP2]]402; CHECK-NEXT:    [[TMP3:%.*]] = mul i16 [[TMP0]], 8403; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <8 x i16> poison, i16 [[TMP3]], i64 0404; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <8 x i16> [[BROADCAST_SPLATINSERT]], <8 x i16> poison, <8 x i32> zeroinitializer405; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]406; CHECK:       [[VECTOR_BODY]]:407; CHECK-NEXT:    [[TMP4:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]408; CHECK-NEXT:    [[VEC_IND:%.*]] = phi <8 x i16> [ [[INDUCTION]], %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[VECTOR_BODY]] ]409; CHECK-NEXT:    [[TMP5:%.*]] = sub <8 x i16> [[VEC_IND]], [[DOTSPLAT]]410; CHECK-NEXT:    [[TMP6:%.*]] = getelementptr inbounds i16, ptr [[DST]], i64 [[TMP4]]411; CHECK-NEXT:    store <8 x i16> [[TMP5]], ptr [[TMP6]], align 2412; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[TMP4]], 8413; CHECK-NEXT:    [[VEC_IND_NEXT]] = add <8 x i16> [[VEC_IND]], [[BROADCAST_SPLAT]]414; CHECK-NEXT:    [[TMP8:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]415; CHECK-NEXT:    br i1 [[TMP8]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP11:![0-9]+]]416; CHECK:       [[MIDDLE_BLOCK]]:417; CHECK-NEXT:    [[CMP_N:%.*]] = icmp eq i64 [[N]], [[N_VEC]]418; CHECK-NEXT:    br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]419; CHECK:       [[SCALAR_PH]]:420; CHECK-NEXT:    [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]421; CHECK-NEXT:    [[BC_RESUME_VAL5:%.*]] = phi i16 [ [[TMP1]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]422; CHECK-NEXT:    br label %[[LOOP:.*]]423; CHECK:       [[LOOP]]:424; CHECK-NEXT:    [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]425; CHECK-NEXT:    [[IV_2:%.*]] = phi i16 [ [[BC_RESUME_VAL5]], %[[SCALAR_PH]] ], [ [[SUB:%.*]], %[[LOOP]] ]426; CHECK-NEXT:    [[SUB]] = sub i16 [[IV_2]], [[O_1]]427; CHECK-NEXT:    [[GEP_DST:%.*]] = getelementptr inbounds i16, ptr [[DST]], i64 [[IV]]428; CHECK-NEXT:    store i16 [[SUB]], ptr [[GEP_DST]], align 2429; CHECK-NEXT:    [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1430; CHECK-NEXT:    [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]431; CHECK-NEXT:    br i1 [[EC]], label %[[EXIT]], label %[[LOOP]], !llvm.loop [[LOOP12:![0-9]+]]432; CHECK:       [[EXIT]]:433; CHECK-NEXT:    ret void434;435entry:436  %o.1 = add i16 %off, 2437  br label %loop438 439loop:440  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]441  %iv.2 = phi i16 [ 0, %entry ], [ %sub, %loop ]442  %sub = sub i16 %iv.2, %o.1443  %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv444  store i16 %sub, ptr %gep.dst, align 2445  %iv.next = add nuw nsw i64 %iv, 1446  %ec = icmp eq i64 %iv.next, %N447  br i1 %ec , label %exit, label %loop448 449exit:450  ret void451}452;.453; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]]}454; CHECK: [[META1]] = !{!"llvm.loop.isvectorized", i32 1}455; CHECK: [[META2]] = !{!"llvm.loop.unroll.runtime.disable"}456; CHECK: [[LOOP3]] = distinct !{[[LOOP3]], [[META2]], [[META1]]}457; CHECK: [[LOOP4]] = distinct !{[[LOOP4]], [[META1]], [[META2]]}458; CHECK: [[LOOP5]] = distinct !{[[LOOP5]], [[META2]], [[META1]]}459; CHECK: [[LOOP6]] = distinct !{[[LOOP6]], [[META1]], [[META2]]}460; CHECK: [[LOOP7]] = distinct !{[[LOOP7]], [[META2]], [[META1]]}461; CHECK: [[LOOP8]] = distinct !{[[LOOP8]], [[META1]], [[META2]]}462; CHECK: [[LOOP9]] = distinct !{[[LOOP9]], [[META1]], [[META2]]}463; CHECK: [[LOOP10]] = distinct !{[[LOOP10]], [[META2]], [[META1]]}464; CHECK: [[LOOP11]] = distinct !{[[LOOP11]], [[META1]], [[META2]]}465; CHECK: [[LOOP12]] = distinct !{[[LOOP12]], [[META2]], [[META1]]}466;.467