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] C++23 Assume keyword not being used for vectorization Date: Wed, 08 May 2024 20:53:36 +0000 [thread overview] Message-ID: <bug-114995-4-kEwaXOAcB7@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-114995-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114995 --- Comment #6 from Pratik Chowdhury <pratikc at live dot co.uk> --- > [[assume((uintptr_t(x_array) & (32-1)) == 0)]]; The Parans in the & have definitely given someone sleepless nights LOL. I myself was saved by the warnings. > Right now we don't always prop back what information we get from the assume attributes. Maybe with the recent prange addition, it can for pointers ... Aah Guess we will switch to assume in the future. I tried [something else just about now](https://gcc.godbolt.org/z/d8aPjzMhq) I think its a bit wrong. Clang seems to be able to handle it. Is this syntax even valid? ```cpp if(reinterpret_cast<::std::uintptr_t>(__builtin_assume_aligned((void*)(mul_array), 32)) != reinterpret_cast<::std::uintptr_t>(mul_array)) { __builtin_unreachable(); } if(reinterpret_cast<::std::uintptr_t>(__builtin_assume_aligned((void*)(add_array), 32)) != reinterpret_cast<::std::uintptr_t>(add_array)) { __builtin_unreachable(); } if(reinterpret_cast<::std::uintptr_t>(__builtin_assume_aligned((void*)(x_array), 32)) != reinterpret_cast<::std::uintptr_t>(x_array)) { __builtin_unreachable(); } ``` I have my doubts on the previous one But this should ideally be valid ```cpp if((reinterpret_cast<::std::uintptr_t>(__builtin_assume_aligned((void*)(mul_array), 32)) & (32-1)) != 0) { __builtin_unreachable(); } if((reinterpret_cast<::std::uintptr_t>(__builtin_assume_aligned((void*)(add_array), 32)) & (32-1)) != 0) { __builtin_unreachable(); } if((reinterpret_cast<::std::uintptr_t>(__builtin_assume_aligned((void*)(x_array), 32)) & (32-1)) != 0) { __builtin_unreachable(); } ``` But either of them are unable to change the Load Stores from Unaligned to Aligned. Maybe victims of aggressive Dead Code elimination here? GCC intrinsics believe that there can be no case its false and the code is deleted for the same? Because __builtin_assume_aligned should always be a multiple of 32 in the above cases. Or __builtin_assume_aligned does not support usage like this in GCC and in Clang it does? And due to that difference, we have a difference in behavior. Its pretty interesting either way.
next prev parent reply other threads:[~2024-05-08 20:53 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-08 20:14 [Bug tree-optimization/114995] New: " pratikc at live dot co.uk 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 [this message] 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-kEwaXOAcB7@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).