From: Matthias Kretz Date: Fri, 13 Jan 2023 15:20:36 +0000 (+0100) Subject: libstdc++: Ensure __builtin_constant_p isn't lost on the way X-Git-Tag: releases/gcc-12.3.0~336 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1084be3151d447cffe2d36667e67939dcdf3e75;p=thirdparty%2Fgcc.git libstdc++: Ensure __builtin_constant_p isn't lost on the way The more expensive code path should only be taken if it can be optimized away. Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h (_SimdWrapper::_M_is_constprop_none_of) (_SimdWrapper::_M_is_constprop_all_of): Return false unless the computed result still satisfies __builtin_constant_p. (cherry picked from commit fea34ee491104f325682cc5fb75683b7d74a0a3b) --- diff --git a/libstdc++-v3/include/experimental/bits/simd.h b/libstdc++-v3/include/experimental/bits/simd.h index b0226fa4c530..2b1e5bcbe946 100644 --- a/libstdc++-v3/include/experimental/bits/simd.h +++ b/libstdc++-v3/include/experimental/bits/simd.h @@ -2673,7 +2673,8 @@ template else __execute_n_times<_Width>( [&](auto __i) { __r &= _M_data[__i.value] == _Tp(); }); - return __r; + if (__builtin_constant_p(__r)) + return __r; } return false; } @@ -2693,7 +2694,8 @@ template else __execute_n_times<_Width>( [&](auto __i) { __r &= _M_data[__i.value] == ~_Tp(); }); - return __r; + if (__builtin_constant_p(__r)) + return __r; } return false; }