public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pratikc at live dot co.uk" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114995] New: C++23 Assume keyword not being used for vectorization Date: Wed, 08 May 2024 20:14:54 +0000 [thread overview] Message-ID: <bug-114995-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114995 Bug ID: 114995 Summary: C++23 Assume keyword not being used for vectorization Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pratikc at live dot co.uk Target Milestone: --- I would like to share a [simple example](https://gcc.godbolt.org/z/dbTsb3YMG) In this, as can be seen in the _second function_ 1. GCC is able to take advantage of builtin_unreachable (because removing it would change the line count) 2. GCC is able to take advantage of __builtin_assume_aligned. (Aligned Loads and Stores) Both of these seem fair However, in the _first function_:- 1. [Assume Keyword](https://en.cppreference.com/w/cpp/language/attributes/assume) is used 2. Unaligned Load Store is generated by GCC 3. Modulo operation advantage is not taken by GCC. Clang seems to be taking advantage of the same though. It seems that thanks to the assume keyword there is scope for further optimization gains. The following syntax also seems to work in Clang ```cpp [[assume(__builtin_assume_aligned(x_array, 32))]]; [[assume(__builtin_assume_aligned(mul_array, 32))]]; [[assume(__builtin_assume_aligned(add_array, 32))]]; ``` Why I wanted to use the assume keyword? 1. There is scope for increased const correctness 2. Looks nicer ```cpp /// @note This prototype works void MulAddLoop(const float* const __restrict mul_array, const float*const __restrict add_array, const ::std::size_t size, float* const __restrict x_array) { ``` PS:- 1. This is my first time filing a GCC Issue Report (I wouldn't really call this a bug) 2. I hope I linked to the correct component as I am not as well versed as I hope I could be with the internals of GCC.
next reply other threads:[~2024-05-08 20:14 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-08 20:14 pratikc at live dot co.uk [this message] 2024-05-08 20:18 ` [Bug tree-optimization/114995] " pinskia at gcc dot gnu.org 2024-05-08 20:20 ` pinskia at gcc dot gnu.org 2024-05-08 20:26 ` pratikc at live dot co.uk 2024-05-08 20:29 ` pinskia at gcc dot gnu.org 2024-05-08 20:33 ` pinskia at gcc dot gnu.org 2024-05-08 20:53 ` pratikc at live dot co.uk 2024-05-08 21:52 ` jakub at gcc dot gnu.org 2024-05-09 19:59 ` pratikc at live dot co.uk 2024-05-14 9:00 ` aldyh at gcc dot gnu.org 2024-05-14 9:04 ` aldyh at gcc dot gnu.org 2024-05-14 9:15 ` aldyh at gcc dot gnu.org 2024-05-15 10:33 ` cvs-commit at gcc dot gnu.org 2024-05-15 10:34 ` aldyh at gcc dot gnu.org
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-114995-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).