From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7857) id 443A43858D33; Thu, 16 Feb 2023 14:58:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 443A43858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676559526; bh=VUGzyjPJoTPtZF/k0uRZK9uY3g/XDKVZcYRPZj/hypc=; h=From:To:Subject:Date:From; b=SWwSvhX650T5XWbDvomo36XmG6OA1p9OUqHtN84gqblTF/5O474HJGjzBrvdylE0X STWLr7D2fT0aOEoM/hskH8wqAAhfOTD0c1gmXKwa4wK3bWQPqktvbk0TY49o5qShhq gcrMt/q+QsAax/CsQf6r5l3R4QbaexX0wQuLHbWg= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Matthias Kretz To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-6089] libstdc++: Ensure __builtin_constant_p isn't lost on the way X-Act-Checkin: gcc X-Git-Author: Matthias Kretz X-Git-Refname: refs/heads/master X-Git-Oldrev: feff71e035c2948c3e4cbcc06adf1ed633e3bd50 X-Git-Newrev: fea34ee491104f325682cc5fb75683b7d74a0a3b Message-Id: <20230216145846.443A43858D33@sourceware.org> Date: Thu, 16 Feb 2023 14:58:46 +0000 (GMT) List-Id: https://gcc.gnu.org/g:fea34ee491104f325682cc5fb75683b7d74a0a3b commit r13-6089-gfea34ee491104f325682cc5fb75683b7d74a0a3b Author: Matthias Kretz Date: Fri Jan 13 16:20:36 2023 +0100 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. Diff: --- libstdc++-v3/include/experimental/bits/simd.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/experimental/bits/simd.h b/libstdc++-v3/include/experimental/bits/simd.h index e76f4781fa6..3de966bbf22 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; }