• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s  -loop-vectorize -force-vector-interleave=4 -pass-remarks='loop-vectorize' -disable-output -S 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
3; RUN: opt < %s  -loop-vectorize -force-vector-interleave=4 -S | FileCheck %s
4
5; These tests are to check that fold-tail procedure produces correct scalar code when
6; loop-vectorization is only unrolling but not vectorizing.
7
8; CHECK-REMARKS:      remark: {{.*}} interleaved loop (interleaved count: 4)
9; CHECK-REMARKS-NEXT: remark: {{.*}} interleaved loop (interleaved count: 4)
10; CHECK-REMARKS-NOT:  remark: {{.*}} vectorized loop
11
12define void @VF1-VPlanExe() {
13; CHECK-LABEL: @VF1-VPlanExe(
14; CHECK-NEXT:  entry:
15; CHECK-NEXT:    br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
16; CHECK:       vector.ph:
17; CHECK-NEXT:    br label [[VECTOR_BODY:%.*]]
18; CHECK:       vector.body:
19; CHECK-NEXT:    [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
20; CHECK-NEXT:    [[INDUCTION:%.*]] = add i64 [[INDEX]], 0
21; CHECK-NEXT:    [[INDUCTION1:%.*]] = add i64 [[INDEX]], 1
22; CHECK-NEXT:    [[INDUCTION2:%.*]] = add i64 [[INDEX]], 2
23; CHECK-NEXT:    [[INDUCTION3:%.*]] = add i64 [[INDEX]], 3
24; CHECK-NEXT:    [[INDEX_NEXT]] = add i64 [[INDEX]], 4
25; CHECK-NEXT:    [[TMP0:%.*]] = icmp eq i64 [[INDEX_NEXT]], 16
26; CHECK-NEXT:    br i1 [[TMP0]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop !0
27; CHECK:       middle.block:
28; CHECK-NEXT:    br i1 true, label [[FOR_COND_CLEANUP:%.*]], label [[SCALAR_PH]]
29; CHECK:       scalar.ph:
30; CHECK-NEXT:    [[BC_RESUME_VAL:%.*]] = phi i64 [ 16, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
31; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
32; CHECK:       for.cond.cleanup:
33; CHECK-NEXT:    ret void
34; CHECK:       for.body:
35; CHECK-NEXT:    [[INDVARS_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
36; CHECK-NEXT:    [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
37; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 15
38; CHECK-NEXT:    br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY]], !llvm.loop !2
39;
40entry:
41  br label %for.body
42
43for.cond.cleanup:
44  ret void
45
46for.body:
47  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
48  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
49  %exitcond = icmp eq i64 %indvars.iv.next, 15
50  br i1 %exitcond, label %for.cond.cleanup, label %for.body
51}
52
53define void @VF1-VPWidenCanonicalIVRecipeExe(double* %ptr1) {
54; CHECK-LABEL: @VF1-VPWidenCanonicalIVRecipeExe(
55; CHECK-NEXT:  entry:
56; CHECK-NEXT:    [[PTR2:%.*]] = getelementptr inbounds double, double* [[PTR1:%.*]], i64 15
57; CHECK-NEXT:    br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
58; CHECK:       vector.ph:
59; CHECK-NEXT:    [[IND_END:%.*]] = getelementptr double, double* [[PTR1]], i64 16
60; CHECK-NEXT:    br label [[VECTOR_BODY:%.*]]
61; CHECK:       vector.body:
62; CHECK-NEXT:    [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
63; CHECK-NEXT:    [[TMP0:%.*]] = add i64 [[INDEX]], 0
64; CHECK-NEXT:    [[NEXT_GEP:%.*]] = getelementptr double, double* [[PTR1]], i64 [[TMP0]]
65; CHECK-NEXT:    [[TMP1:%.*]] = add i64 [[INDEX]], 1
66; CHECK-NEXT:    [[NEXT_GEP1:%.*]] = getelementptr double, double* [[PTR1]], i64 [[TMP1]]
67; CHECK-NEXT:    [[TMP2:%.*]] = add i64 [[INDEX]], 2
68; CHECK-NEXT:    [[NEXT_GEP2:%.*]] = getelementptr double, double* [[PTR1]], i64 [[TMP2]]
69; CHECK-NEXT:    [[TMP3:%.*]] = add i64 [[INDEX]], 3
70; CHECK-NEXT:    [[NEXT_GEP3:%.*]] = getelementptr double, double* [[PTR1]], i64 [[TMP3]]
71; CHECK-NEXT:    [[INDEX_NEXT]] = add i64 [[INDEX]], 4
72; CHECK-NEXT:    [[TMP4:%.*]] = icmp eq i64 [[INDEX_NEXT]], 16
73; CHECK-NEXT:    br i1 [[TMP4]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop !3
74; CHECK:       middle.block:
75; CHECK-NEXT:    br i1 true, label [[FOR_COND_CLEANUP:%.*]], label [[SCALAR_PH]]
76; CHECK:       scalar.ph:
77; CHECK-NEXT:    [[BC_RESUME_VAL:%.*]] = phi double* [ [[IND_END]], [[MIDDLE_BLOCK]] ], [ [[PTR1]], [[ENTRY:%.*]] ]
78; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
79; CHECK:       for.cond.cleanup:
80; CHECK-NEXT:    ret void
81; CHECK:       for.body:
82; CHECK-NEXT:    [[ADDR:%.*]] = phi double* [ [[PTR:%.*]], [[FOR_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
83; CHECK-NEXT:    [[PTR]] = getelementptr inbounds double, double* [[ADDR]], i64 1
84; CHECK-NEXT:    [[COND:%.*]] = icmp eq double* [[PTR]], [[PTR2]]
85; CHECK-NEXT:    br i1 [[COND]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY]], !llvm.loop !4
86;
87entry:
88  %ptr2 = getelementptr inbounds double, double* %ptr1, i64 15
89  br label %for.body
90
91for.cond.cleanup:
92  ret void
93
94for.body:
95  %addr = phi double* [ %ptr, %for.body ], [ %ptr1, %entry ]
96  %ptr = getelementptr inbounds double, double* %addr, i64 1
97  %cond = icmp eq double* %ptr, %ptr2
98  br i1 %cond, label %for.cond.cleanup, label %for.body
99}
100