[Bug tree-optimization/95926] New: Failure to optimize xor pattern when

gabravier at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Jun 27 02:08:10 GMT 2020


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

            Bug ID: 95926
           Summary: Failure to optimize xor pattern when
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

bool f(bool a, bool b)
{
    bool tmp = a & b;
    return (tmp ^ b) | (tmp ^ a);
}

This code does not optimize as well as this code :

bool f(bool a, bool b)
{
    return ((a & b) ^ b) | ((a & b) ^ a);
}

which optimizes to `return a ^ b;`. This seems rather odd considering that they
are equivalent and the first example is just a simplification of the second
(i.e. made more readable).


More information about the Gcc-bugs mailing list