public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "g.peterhoff@t-online.de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109029] New: std::signbit(double) generiert sehr ineffizienten code Date: Sun, 05 Mar 2023 12:08:25 +0000 [thread overview] Message-ID: <bug-109029-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109029 Bug ID: 109029 Summary: std::signbit(double) generiert sehr ineffizienten code Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: g.peterhoff@t-online.de Target Milestone: --- Hallo, std::signbit(double) generiert sehr ineffizienten code und kann somit nicht vektorisiert werden (https://godbolt.org/z/se6Ea8bo9). thx Gero -std=c++20 -march=x86-64-v3 -O3 -mno-vzeroupper #include <cmath> #include <array> #include <numbers> #include <algorithm> static constexpr size_t Size = 1024; using float80_t = long double; using float64_t = double; using float32_t = float; template <typename Type> inline constexpr bool foo(const Type x) noexcept { return std::signbit(x); } template <typename Type> inline constexpr Type bar(const Type x) noexcept { return std::signbit(x) ? std::numbers::pi_v<Type> : 0; } template <typename Container, typename Function> inline constexpr void for_all(Container& cnt, Function&& f) noexcept { std::transform(cnt.begin(), cnt.end(), cnt.begin(), f); } template <typename ContainerRes, typename ContainerArg, typename Function> inline constexpr void for_all(ContainerRes& res, const ContainerArg& arg, Function&& f) noexcept { std::transform(arg.begin(), arg.end(), res.begin(), f); } float64_t foo64(const float64_t x) noexcept { return foo(x); } float32_t foo32(const float32_t x) noexcept { return foo(x); } float64_t bar64(const float64_t x) noexcept { return bar(x); } float32_t bar32(const float32_t x) noexcept { return bar(x); } void foos64(std::array<bool, Size>& res, const std::array<float64_t, Size>& arg) noexcept { for_all(res, arg, foo<float64_t>); } void foos32(std::array<bool, Size>& res, const std::array<float32_t, Size>& arg) noexcept { for_all(res, arg, foo<float32_t>); } void bars64(std::array<float64_t, Size>& cnt) noexcept { for_all(cnt, bar<float64_t>); } void bars32(std::array<float32_t, Size>& cnt) noexcept { for_all(cnt, bar<float32_t>); }
next reply other threads:[~2023-03-05 12:08 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-05 12:08 g.peterhoff@t-online.de [this message] 2023-03-05 12:11 ` [Bug c++/109029] " g.peterhoff@t-online.de 2023-03-05 19:18 ` [Bug tree-optimization/109029] __builtin_signbit for 64bit fp does not vectorize pinskia at gcc dot gnu.org 2023-03-06 8:52 ` rguenth at gcc dot gnu.org 2023-03-31 3:37 ` crazylht at gmail dot com 2023-03-31 4:16 ` crazylht at gmail dot com 2023-03-31 5:47 ` crazylht at gmail dot com 2023-03-31 5:52 ` crazylht at gmail dot com 2023-03-31 6:22 ` crazylht at gmail dot com 2023-03-31 7:19 ` crazylht at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-109029-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).