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

            Bug ID: 66261
           Summary: operations that simplify whether the pointers are the
                    same or not (++p;++q;--p;--q)
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glisse at gcc dot gnu.org
  Target Milestone: ---

In the example below, if p and q refer to different objects, the function does
nothing, and if they refer to the same object, it also does nothing. But we
don't manage to optimize it, and I don't know how we could do it (without being
incredibly specific). It might actually be slightly easier at the RTL level for
targets where adding a constant to an integer in memory is a single insn, so it
could be detected that ++q and --p commute. clang++, icpc and sunCC don't
simplify it either.

void f(int&p,int&q){
  ++p;++q;--p;--q;
}

Reply via email to