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.