https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113046

            Bug ID: 113046
           Summary: Standard algorithms should do de-iterator
                    optimizations
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: unlvsur at live dot com
  Target Milestone: ---

I presented an example on Godbolt indicating that the combined use of
std::vector<int>::iterator with int* result in duplicated code when compared to
using int*, which is not ideal. Additionally, it was observed that GCC and
Clang do not optimize std::vector<int>::iterator as effectively as a
straightforward int*. You can view the example here:
https://godbolt.org/z/x3q18fG3T

To address this issue, I recommend implementing a de-iterator optimization.
This optimization aims to eliminate the abstraction of the contiguous iterator,
treating it as a simple pointer. By doing so, the compiler can merge duplicated
code with a pointer, leading to simplified code and better overall
optimization.

Reply via email to