From 5d6467e7f6a8074a06782ee9cfefed206a7baa4a Mon Sep 17 00:00:00 2001 From: Denes Tarjan Date: Thu, 4 Apr 2024 09:09:02 +0200 Subject: [PATCH 1/2] [NFC] Simplify LoopUnroll2::unroll_n_times to eliminate unused code --- intrinsiccv/include/intrinsiccv/utils.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/intrinsiccv/include/intrinsiccv/utils.h b/intrinsiccv/include/intrinsiccv/utils.h index 8470173ed..fb3a1ed66 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; } -- GitLab From 90203e26efa0bf3433638c8336339475af9f1067 Mon Sep 17 00:00:00 2001 From: Denes Tarjan Date: Thu, 4 Apr 2024 09:10:02 +0200 Subject: [PATCH 2/2] [test] Change test_transpose to full vectors to increase branch coverage --- test/api/test_transpose.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/api/test_transpose.cpp b/test/api/test_transpose.cpp index ddbcc8fff..2ae3d88b6 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); } -- GitLab