diff --git a/intrinsiccv/include/intrinsiccv/utils.h b/intrinsiccv/include/intrinsiccv/utils.h index 8470173ed9bb341be5d59e7645445132781b81aa..fb3a1ed66721bbf1100c66d9f5ddb4a3609ef871 100644 --- a/intrinsiccv/include/intrinsiccv/utils.h +++ b/intrinsiccv/include/intrinsiccv/utils.h @@ -309,24 +309,24 @@ class LoopUnroll2 final { const size_t n_step = UnrollFactor * step(); size_t max_index = index_ + (remaining_length() / n_step) * n_step; - while (remaining_length()) { + if constexpr (try_to_avoid_tail_loop && (UnrollFactor == 1)) { while (index_ < max_index) { - callback(index_); - index_ += n_step; - } + while (index_ < max_index) { + callback(index_); + index_ += n_step; + } - // Try to avoid the tail loop if Tail is TryToAvoidTailLoop - if constexpr (try_to_avoid_tail_loop && (UnrollFactor == 1)) { - if (remaining_length() && (length_ >= n_step)) { + if (remaining_length()) { index_ = length_ - n_step; max_index = length_; - } else { - break; } - } else { - break; } - } // while (remaining_length()) + } else { + while (index_ < max_index) { + callback(index_); + index_ += n_step; + } + } return *this; } diff --git a/test/api/test_transpose.cpp b/test/api/test_transpose.cpp index ddbcc8fffa181fb935db6af078955b303446928d..2ae3d88b60b09a5d3a9146386bbc68913525e705 100644 --- a/test/api/test_transpose.cpp +++ b/test/api/test_transpose.cpp @@ -31,7 +31,7 @@ class TestTranspose final { size_t src_width = 2 * test::Options::vector_lanes(); // Set height to be different from width but still bigger than vector_lanes size_t src_height = - inplace ? src_width : test::Options::vector_lanes() + 1; + inplace ? src_width : 3 * test::Options::vector_lanes(); test(src_width, src_height); }