bool xnor_1( bool x, bool y ) { return !( x ^ y ); }
bool xnor_2( bool x, bool y ) { return ( x && y ) || ( !x && !y ); }

both functions should emit (x==y) code, but _2 isn't optimized.

bool xnor_1(bool, bool) (x, y)
{
  int D.2085;
<bb 0>:
  return x == y;
}

bool xnor_2(bool, bool) (x, y)
{
  bool D.2181;
  int prephitmp.51;
  bool D.2098;
  bool D.2097;
  bool D.2096;
  bool iftmp.0;
  int D.2090;
<bb 0>:
  if (x == 0) goto <L2>; else goto <L0>;
<L0>:;
  (void) 0;
  prephitmp.51 = (int) y;
  goto <bb 3> (<L5>);
<L2>:;
  (void) 0;
  prephitmp.51 = (int) (y == 0);
<L5>:;
  return prephitmp.51;
}


-- 
           Summary: missed xnor optimization.
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pluto at agmk dot net
  GCC host triplet: x86_64-gnu-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42195

Reply via email to