]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
libstdc++: Ensure __builtin_constant_p isn't lost on the way
authorMatthias Kretz <m.kretz@gsi.de>
Fri, 13 Jan 2023 15:20:36 +0000 (16:20 +0100)
committerMatthias Kretz <m.kretz@gsi.de>
Thu, 16 Feb 2023 15:11:26 +0000 (16:11 +0100)
The more expensive code path should only be taken if it can be optimized
away.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
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)

libstdc++-v3/include/experimental/bits/simd.h

index 0e58ae01b17a26fb5703fcfd1dc1a1431f52d0a1..e9a07018cf06a254f43c5277c579c587f2b80c39 100644 (file)
@@ -2546,7 +2546,8 @@ template <typename _Tp, size_t _Width>
          else
            __execute_n_times<_Width>(
              [&](auto __i) { __r &= _M_data[__i.value] == _Tp(); });
-         return __r;
+         if (__builtin_constant_p(__r))
+           return __r;
        }
       return false;
     }
@@ -2566,7 +2567,8 @@ template <typename _Tp, size_t _Width>
          else
            __execute_n_times<_Width>(
              [&](auto __i) { __r &= _M_data[__i.value] == ~_Tp(); });
-         return __r;
+         if (__builtin_constant_p(__r))
+           return __r;
        }
       return false;
     }