In this code,

  unsigned short
  crc (unsigned short crc, unsigned char data)
  {
    unsigned char i, x16;
    for (i = 0; i < 8; i++)
      {
        x16 = (data ^ (unsigned char) crc) & 1;
        data >>= 1;
        if (x16)
          {
            crc ^= 0x4002;
            crc >>= 1;
            crc |= 0x8000;
          }
        else
          crc >>= 1;
      }
    return crc;
  }

the `then' branch of the if-statement should become

  crc >>= 1;
  crc ^= 0xA001;

Seems related to bug 16798.

Paolo


-- 
           Summary: combine misses some distributivity
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bonzini at gnu dot org


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

Reply via email to