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

            Bug ID: 107991
           Summary: Extra mov instructions with ternary on x86
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: denis.campredon at gmail dot com
  Target Milestone: ---

Compiled with -O2 on x86, gcc trunk produces 3 mov instructions for each of the
following functions:

int foo(bool b, int i, int j) {
    return b ? i - j : i;
}

int bar(bool b, int i, int j) {
    return i + (b ? -j : 0);
}

int baz(bool b, int i, int j) {
    return i - (b ? j : 0);
}

-------------

Whearas with gcc 7.5, only 1 mov was produced for foo and bar, and two for baz

Reply via email to