[PATCH 4/4][libstdc++] use pragma GCC 4 preferred for std::find [PR116140]
Jonathan Wakely
jwakely@redhat.com
Tue May 13 10:03:07 GMT 2025
On 13/05/25 10:41 +0100, Tamar Christina wrote:
>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?
This libstdc++ change is OK assuming the compiler changes get approved
(and if the name "preferred" changes, this is still approved with
whatever it changes to).
>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;
>
More information about the Libstdc++
mailing list