| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --filter "br " --filter "^.*:" --filter "icmp" --version 6 |
| ; RUN: opt -passes=loop-vectorize -force-vector-width="vscale x 1" -force-vector-interleave=1 -S %s | FileCheck %s |
| |
| ; Without a vscale for tuning, a VF of vscale x 1 leaves an estimated vector step |
| ; of 1, for which every estimated trip count is a multiple of the step. Check |
| ; that neither successor of the middle block's terminator ends up with a weight |
| ; of zero, which would give the loop the terminator leaves a profile count of 0. |
| define void @vector_step_of_one(ptr %p, i64 %n) !prof !0 { |
| ; CHECK-LABEL: define void @vector_step_of_one( |
| ; CHECK-SAME: ptr [[P:%.*]], i64 [[N:%.*]]) !prof [[PROF0:![0-9]+]] { |
| ; CHECK: [[ENTRY:.*:]] |
| ; CHECK: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[N]], [[TMP0:%.*]] |
| ; CHECK: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]], !prof [[PROF1:![0-9]+]] |
| ; CHECK: [[VECTOR_PH]]: |
| ; CHECK: br label %[[VECTOR_BODY:.*]] |
| ; CHECK: [[VECTOR_BODY]]: |
| ; CHECK: [[TMP2:%.*]] = icmp eq i64 [[INDEX_NEXT:%.*]], [[N_VEC:%.*]] |
| ; CHECK: br i1 [[TMP2]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !prof [[PROF2:![0-9]+]], !llvm.loop [[LOOP3:![0-9]+]] |
| ; CHECK: [[MIDDLE_BLOCK]]: |
| ; CHECK: [[CMP_N:%.*]] = icmp eq i64 [[N]], [[N_VEC]] |
| ; CHECK: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]], !prof [[PROF7:![0-9]+]] |
| ; CHECK: [[SCALAR_PH]]: |
| ; CHECK: br label %[[LOOP:.*]] |
| ; CHECK: [[LOOP]]: |
| ; CHECK: [[CMP_LOOP:%.*]] = icmp eq i64 [[IV_NEXT:%.*]], [[N]] |
| ; CHECK: br i1 [[CMP_LOOP]], label %[[EXIT]], label %[[LOOP]], !prof [[PROF7]], !llvm.loop [[LOOP8:![0-9]+]] |
| ; CHECK: [[EXIT]]: |
| ; |
| entry: |
| br label %loop |
| |
| loop: |
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ] |
| %ptr = getelementptr inbounds i32, ptr %p, i64 %iv |
| store i32 0, ptr %ptr |
| %iv.next = add i64 %iv, 1 |
| %cmp.loop = icmp eq i64 %iv.next, %n |
| br i1 %cmp.loop, label %exit, label %loop, !prof !1 |
| |
| exit: |
| ret void |
| } |
| |
| !0 = !{!"function_entry_count", i64 13} |
| ; The estimated trip count is 1024. |
| !1 = !{!"branch_weights", i32 1, i32 1023} |
| ;. |
| ; CHECK: [[PROF0]] = !{!"function_entry_count", i64 13} |
| ; CHECK: [[PROF1]] = !{!"branch_weights", i32 1, i32 127} |
| ; CHECK: [[PROF2]] = !{!"branch_weights", i32 1, i32 1023} |
| ; CHECK: [[LOOP3]] = distinct !{[[LOOP3]], [[META4:![0-9]+]], [[META5:![0-9]+]], [[META6:![0-9]+]]} |
| ; CHECK: [[META4]] = !{!"llvm.loop.isvectorized", i32 1} |
| ; CHECK: [[META5]] = !{!"llvm.loop.unroll.runtime.disable"} |
| ; CHECK: [[META6]] = !{!"llvm.loop.estimated_trip_count", i32 1024} |
| ; CHECK: [[PROF7]] = !{!"branch_weights", i32 1, i32 0} |
| ; CHECK: [[LOOP8]] = distinct !{[[LOOP8]], [[META5]], [[META4]], [[META9:![0-9]+]]} |
| ; CHECK: [[META9]] = !{!"llvm.loop.estimated_trip_count", i32 0} |
| ;. |