brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · b5e7e67 Raw
76 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -S -passes=loop-vectorize -force-vector-interleave=2 | FileCheck %s3 4; Demonstrate a case where we unroll a loop, but don't vectorize it.5; The original loop runs stores in the latch block on iterations 0 to 1022,6; and exits when %indvars.iv = 1023. (That is, it actually runs the stores7; for an odd number of iterations.)  If we unroll by two in the "vector.body"8; loop, we must exit to the epilogue on iteration with %indvars.iv = 1022 to9; avoid an out of bounds access.10 11define void @test(ptr %data) {12; CHECK-LABEL: @test(13; CHECK-NEXT:  entry:14; CHECK-NEXT:    br label [[VECTOR_PH:%.*]]15; CHECK:       vector.ph:16; CHECK-NEXT:    br label [[VECTOR_BODY:%.*]]17; CHECK:       vector.body:18; CHECK-NEXT:    [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]19; CHECK-NEXT:    [[TMP1:%.*]] = add i64 [[INDEX]], 120; CHECK-NEXT:    [[TMP2:%.*]] = shl nuw nsw i64 [[INDEX]], 121; CHECK-NEXT:    [[TMP3:%.*]] = shl nuw nsw i64 [[TMP1]], 122; CHECK-NEXT:    [[TMP4:%.*]] = or disjoint i64 [[TMP2]], 123; CHECK-NEXT:    [[TMP5:%.*]] = or disjoint i64 [[TMP3]], 124; CHECK-NEXT:    [[TMP6:%.*]] = getelementptr inbounds double, ptr [[DATA:%.*]], i64 [[TMP4]]25; CHECK-NEXT:    [[TMP7:%.*]] = getelementptr inbounds double, ptr [[DATA]], i64 [[TMP5]]26; CHECK-NEXT:    [[TMP8:%.*]] = load double, ptr [[TMP6]], align 827; CHECK-NEXT:    [[TMP9:%.*]] = load double, ptr [[TMP7]], align 828; CHECK-NEXT:    [[TMP10:%.*]] = fneg double [[TMP8]]29; CHECK-NEXT:    [[TMP11:%.*]] = fneg double [[TMP9]]30; CHECK-NEXT:    store double [[TMP10]], ptr [[TMP6]], align 831; CHECK-NEXT:    store double [[TMP11]], ptr [[TMP7]], align 832; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 233; CHECK-NEXT:    [[TMP12:%.*]] = icmp eq i64 [[INDEX_NEXT]], 102234; CHECK-NEXT:    br i1 [[TMP12]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]35; CHECK:       middle.block:36; CHECK-NEXT:    br label [[SCALAR_PH:%.*]]37; CHECK:       scalar.ph:38; CHECK-NEXT:    br label [[FOR_BODY:%.*]]39; CHECK:       for.body:40; CHECK-NEXT:    [[INDVARS_IV:%.*]] = phi i64 [ 1022, [[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_LATCH:%.*]] ]41; CHECK-NEXT:    [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 142; CHECK-NEXT:    [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 102443; CHECK-NEXT:    br i1 [[EXITCOND_NOT]], label [[FOR_END:%.*]], label [[FOR_LATCH]]44; CHECK:       for.latch:45; CHECK-NEXT:    [[T15:%.*]] = shl nuw nsw i64 [[INDVARS_IV]], 146; CHECK-NEXT:    [[T16:%.*]] = or disjoint i64 [[T15]], 147; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds double, ptr [[DATA]], i64 [[T16]]48; CHECK-NEXT:    [[T17:%.*]] = load double, ptr [[ARRAYIDX]], align 849; CHECK-NEXT:    [[FNEG:%.*]] = fneg double [[T17]]50; CHECK-NEXT:    store double [[FNEG]], ptr [[ARRAYIDX]], align 851; CHECK-NEXT:    br label [[FOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]]52; CHECK:       for.end:53; CHECK-NEXT:    ret void54;55entry:56  br label %for.body57 58for.body:59  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.latch ]60  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 161  %exitcond.not = icmp eq i64 %indvars.iv.next, 102462  br i1 %exitcond.not, label %for.end, label %for.latch63 64for.latch:65  %t15 = shl nuw nsw i64 %indvars.iv, 166  %t16 = or disjoint i64 %t15, 167  %arrayidx = getelementptr inbounds double, ptr %data, i64 %t1668  %t17 = load double, ptr %arrayidx, align 869  %fneg = fneg double %t1770  store double %fneg, ptr %arrayidx, align 871  br label %for.body72 73for.end:74  ret void75}76