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

            Bug ID: 89859
           Summary: Addition of __restrict generates worse assembly
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: john.boyer at tutanota dot com
  Target Milestone: ---

With the following function signature (that is within a struct):

void compute(int *__restrict x) { /* ... */ }

Adding an additional __restrict for the this pointer as such:

void compute(int *__restrict x) __restrict { /* ... */ }

Will generate worse assembly. Restrict is only supposed to prohibit aliasing,
so this addition should either make the assembly better or the same.

Here is a full reproducible example: https://godbolt.org/z/SiYE7H.
Compare the assembly for the test::compute() method in both panes.
You will see with the additional __restrict, there is two additional move
instructions.

Reply via email to