Hi All, In PR116140 it was brought up that adding pragma GCC unroll in std::find makes it so that you can't use a larger unroll factor if you wanted to. This is because the value can't be overriden by the other unrolling flags such as -funroll-loops.
To know whether this should be possible to do or not this proposes an extension to the pragma GCC unroll with an argument to indicate if we can override the value or not. The default is "requested" to match what it does today. This patch changes the form for __find_if into "preferred" to allow further unroller should the user want to. Bootstrapped Regtested on aarch64-none-linux-gnu, arm-none-linux-gnueabihf, x86_64-pc-linux-gnu -m32, -m64 and no issues. Ok for master? Thanks, Tamar libstdc++-v3/ChangeLog: PR libstdc++/116140 * include/bits/stl_algobase.h (__find_if): Set unrolling to preferred rather than requested. --- diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 119dbe9a0936b33ad96d1553f133d9cd9bec5338..a0d2bdce677d4c999324217dd21f3566937fff2a 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -2091,7 +2091,7 @@ _GLIBCXX_END_NAMESPACE_ALGO inline _Iterator __find_if(_Iterator __first, _Iterator __last, _Predicate __pred) { -#pragma GCC unroll 4 +#pragma GCC unroll 4 preferred while (__first != __last && !__pred(__first)) ++__first; return __first; --
diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 119dbe9a0936b33ad96d1553f133d9cd9bec5338..a0d2bdce677d4c999324217dd21f3566937fff2a 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -2091,7 +2091,7 @@ _GLIBCXX_END_NAMESPACE_ALGO inline _Iterator __find_if(_Iterator __first, _Iterator __last, _Predicate __pred) { -#pragma GCC unroll 4 +#pragma GCC unroll 4 preferred while (__first != __last && !__pred(__first)) ++__first; return __first;