public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114995] New: C++23 Assume keyword not being used for vectorization
@ 2024-05-08 20:14 pratikc at live dot co.uk
  2024-05-08 20:18 ` [Bug tree-optimization/114995] " pinskia at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: pratikc at live dot co.uk @ 2024-05-08 20:14 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-05-15 10:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-08 20:14 [Bug tree-optimization/114995] New: C++23 Assume keyword not being used for vectorization 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
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

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).