From 530b41dad9cf90e29d8aebc823589e16ff5d40ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 29 Mar 2026 22:56:47 +0200 Subject: [PATCH] Add BOOST_CONTAINER_ENABLE_SEGMENTED_LOOP_UNROLLING / BOOST_CONTAINER_DISABLE_SEGMENTED_LOOP_UNROLLING options to easier test unrolling. --- .../experimental/segmented_iterator_traits.hpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/include/boost/container/experimental/segmented_iterator_traits.hpp b/include/boost/container/experimental/segmented_iterator_traits.hpp index 53efeaa..d79e1b5 100644 --- a/include/boost/container/experimental/segmented_iterator_traits.hpp +++ b/include/boost/container/experimental/segmented_iterator_traits.hpp @@ -146,10 +146,22 @@ struct is_sentinel #include -#define BOOST_CONTAINER_DISABLE_SEGMENTED_LOOP_UNROLLING +//#define BOOST_CONTAINER_ENABLE_SEGMENTED_LOOP_UNROLLING +//#define BOOST_CONTAINER_DISABLE_SEGMENTED_LOOP_UNROLLING -#ifndef BOOST_CONTAINER_DISABLE_SEGMENTED_LOOP_UNROLLING -#define BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING +#if defined(BOOST_CONTAINER_ENABLE_SEGMENTED_LOOP_UNROLLING) && defined(BOOST_CONTAINER_DISABLE_SEGMENTED_LOOP_UNROLLING) + #error "Cannot define both BOOST_CONTAINER_ENABLE_SEGMENTED_LOOP_UNROLLING and BOOST_CONTAINER_DISABLE_SEGMENTED_LOOP_UNROLLING" +#elif !defined(BOOST_CONTAINER_ENABLE_SEGMENTED_LOOP_UNROLLING) && !defined(BOOST_CONTAINER_DISABLE_SEGMENTED_LOOP_UNROLLING) + //Disable loop unrolling for clang, which generates suboptimal code in some case as clang auto-vectorizes + //loops more aggressively than other compilers, and loop unrolling can interfere with this optimization. + #if !defined(BOOST_CLANG) + #define BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING + #endif +#elif defined(BOOST_CONTAINER_ENABLE_SEGMENTED_LOOP_UNROLLING) + //Force loop unrolling + #define BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING +#else //defined(BOOST_CONTAINER_DISABLE_SEGMENTED_LOOP_UNROLLING) + // Force no loop unrolling #endif #endif // BOOST_CONTAINER_EXPERIMENTAL_SEGMENTED_ITERATOR_TRAITS_HPP