1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -passes=loop-vectorize -force-vector-interleave=3 -force-vector-width=2 -S | FileCheck %s 3 4target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 5 6; Make sure the loop is vectorized and unrolled under -Os without folding its 7; tail based on its trip-count being provably divisible by chosen VFxIC. 8 9define dso_local void @constTC(i32* noalias nocapture %A) optsize { 10; CHECK-LABEL: @constTC( 11; CHECK-NEXT: entry: 12; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] 13; CHECK: vector.ph: 14; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 15; CHECK: vector.body: 16; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 17; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[INDEX]], 0 18; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[INDEX]], 2 19; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[INDEX]], 4 20; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[TMP0]] 21; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds i32, i32* [[A]], i32 [[TMP1]] 22; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds i32, i32* [[A]], i32 [[TMP2]] 23; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i32, i32* [[TMP3]], i32 0 24; CHECK-NEXT: [[TMP7:%.*]] = bitcast i32* [[TMP6]] to <2 x i32>* 25; CHECK-NEXT: store <2 x i32> <i32 13, i32 13>, <2 x i32>* [[TMP7]], align 1 26; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds i32, i32* [[TMP3]], i32 2 27; CHECK-NEXT: [[TMP9:%.*]] = bitcast i32* [[TMP8]] to <2 x i32>* 28; CHECK-NEXT: store <2 x i32> <i32 13, i32 13>, <2 x i32>* [[TMP9]], align 1 29; CHECK-NEXT: [[TMP10:%.*]] = getelementptr inbounds i32, i32* [[TMP3]], i32 4 30; CHECK-NEXT: [[TMP11:%.*]] = bitcast i32* [[TMP10]] to <2 x i32>* 31; CHECK-NEXT: store <2 x i32> <i32 13, i32 13>, <2 x i32>* [[TMP11]], align 1 32; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 6 33; CHECK-NEXT: [[TMP12:%.*]] = icmp eq i32 [[INDEX_NEXT]], 1800 34; CHECK-NEXT: br i1 [[TMP12]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP0:!llvm.loop !.*]] 35; CHECK: middle.block: 36; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i32 1800, 1800 37; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[SCALAR_PH]] 38; CHECK: scalar.ph: 39; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i32 [ 1800, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ] 40; CHECK-NEXT: br label [[LOOP:%.*]] 41; CHECK: loop: 42; CHECK-NEXT: [[RIV:%.*]] = phi i32 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[RIVPLUS1:%.*]], [[LOOP]] ] 43; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A]], i32 [[RIV]] 44; CHECK-NEXT: store i32 13, i32* [[ARRAYIDX]], align 1 45; CHECK-NEXT: [[RIVPLUS1]] = add nuw nsw i32 [[RIV]], 1 46; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[RIVPLUS1]], 1800 47; CHECK-NEXT: br i1 [[COND]], label [[EXIT]], label [[LOOP]], [[LOOP2:!llvm.loop !.*]] 48; CHECK: exit: 49; CHECK-NEXT: ret void 50; 51entry: 52 br label %loop 53 54loop: 55 %riv = phi i32 [ 0, %entry ], [ %rivPlus1, %loop ] 56 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %riv 57 store i32 13, i32* %arrayidx, align 1 58 %rivPlus1 = add nuw nsw i32 %riv, 1 59 %cond = icmp eq i32 %rivPlus1, 1800 60 br i1 %cond, label %exit, label %loop 61 62exit: 63 ret void 64} 65