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

            Bug ID: 113186
           Summary: [13/14 Regression] `(a^c) & (a^!c)` is not optimized
                    to 0 for bool
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
bool f(bool a, bool c)
{
  bool b = (a^c);
  bool d = (a^!c);
  return b & d;
}
```
This should optimize to 0 but does not since GCC 13. With the C++ front-end, I
suspect since r13-1779-g375668e0508fbe . With the C front-end, it started on
the trunk.

For C have in forwprop1:
  b_7 = a_5(D) ^ c_6(D);
  _11 = a_5(D) ^ c_6(D);
  _12 = a_5(D) == c_6(D);
  _13 = b_7 & _12;

For C++ we have (at -O1):
  b_7 = a_5(D) != c_6(D);
  _1 = ~c_6(D);
  d_8 = _1 != a_5(D);
  _11 = b_7 & d_8;

For C++ at -O2 in forwprop2, we have similar as what with the C front-end.

Reply via email to