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

            Bug ID: 67879
           Summary: unnecessary jump in ternary
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marccelani at fb dot com
  Target Milestone: ---

The following functions f and f2 should compile the same, but f includes a jump
whereas f2 properly avoids the jump and adds the result of the comparison.

int f(int a, int b, int* c) {
    bool x = a < b;
    return x ? *c : *c + 1;
}

int f2(int a, int b, int* c) {
    bool x = a < b;
    return *c + (x ? 0 :  1);
}


https://goo.gl/OFhXTp

Reply via email to