public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112935] New: [14 Regression] Performance regression in Coremarks crcu8 function
@ 2023-12-09  4:16 xry111 at gcc dot gnu.org
  2023-12-09  4:20 ` [Bug tree-optimization/112935] " xry111 at gcc dot gnu.org
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-09  4:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112935
           Summary: [14 Regression] Performance regression in Coremarks
                    crcu8 function
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xry111 at gcc dot gnu.org
  Target Milestone: ---

typedef __UINT8_TYPE__ ee_u8;
typedef __UINT16_TYPE__ ee_u16;

ee_u16 crcu8(ee_u8 data, ee_u16 crc) {
  ee_u8 i = 0, x16 = 0, carry = 0;

  for (i = 0; i < 8; i++) {
    x16 = (ee_u8)((data & 1) ^ ((ee_u8)crc & 1));
    data >>= 1;

    if (x16 == 1) {
      crc ^= 0x4002;
      carry = 1;
    } else
      carry = 0;
    crc >>= 1;
    if (carry)
      crc |= 0x8000;
    else
      crc &= 0x7fff;
  }
  return crc;
}

With GCC 13.2.0 -O2, on LoongArch we get:

.L2:
        xor     $r12,$r4,$r14
        andi    $r12,$r12,1
        sub.w   $r12,$r0,$r12
        srli.w  $r4,$r4,1
        and     $r12,$r12,$r15
        addi.w  $r13,$r13,-1
        xor     $r12,$r12,$r4
        bstrpick.w      $r13,$r13,7,0
        srli.d  $r14,$r14,1
        bstrpick.w      $r4,$r12,15,0
        bnez    $r13,.L2

With GCC 14.0.0 -O2:

.L2:
        xor     $r12,$r4,$r14
        andi    $r12,$r12,1
        mul.w   $r12,$r12,$r15
        srli.w  $r4,$r4,1
        addi.w  $r13,$r13,-1
        bstrpick.w      $r13,$r13,7,0
        srli.d  $r14,$r14,1
        xor     $r12,$r12,$r4
        bstrpick.w      $r4,$r12,15,0
        bnez    $r13,.L2

mul.w is slower than sub.w + and.

I'm now setting components to tree-optimization because the difference already
exists in 254t.optimized vs 263t.optimized.  But maybe the tree optimizer is
doing things correctly and we should just add a target-specific optimization.

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2023-12-11 15:57 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-09  4:16 [Bug tree-optimization/112935] New: [14 Regression] Performance regression in Coremarks crcu8 function xry111 at gcc dot gnu.org
2023-12-09  4:20 ` [Bug tree-optimization/112935] " xry111 at gcc dot gnu.org
2023-12-09  4:20 ` xry111 at gcc dot gnu.org
2023-12-09  4:22 ` pinskia at gcc dot gnu.org
2023-12-09  4:35 ` [Bug target/112935] " pinskia at gcc dot gnu.org
2023-12-09  4:49 ` pinskia at gcc dot gnu.org
2023-12-09  6:56 ` xry111 at gcc dot gnu.org
2023-12-09  7:02 ` xry111 at gcc dot gnu.org
2023-12-09  7:05 ` pinskia at gcc dot gnu.org
2023-12-09  7:48 ` xry111 at gcc dot gnu.org
2023-12-09  7:56 ` xry111 at gcc dot gnu.org
2023-12-09  8:58 ` xry111 at gcc dot gnu.org
2023-12-09  8:58 ` xry111 at gcc dot gnu.org
2023-12-09  9:06 ` [Bug tree-optimization/112935] " xry111 at gcc dot gnu.org
2023-12-09  9:07 ` [Bug middle-end/112935] " pinskia at gcc dot gnu.org
2023-12-09  9:14 ` xry111 at gcc dot gnu.org
2023-12-09  9:16 ` pinskia at gcc dot gnu.org
2023-12-09  9:21 ` xry111 at gcc dot gnu.org
2023-12-09  9:24 ` pinskia at gcc dot gnu.org
2023-12-09  9:25 ` pinskia at gcc dot gnu.org
2023-12-09 21:43 ` pinskia at gcc dot gnu.org
2023-12-10  9:22 ` pinskia at gcc dot gnu.org
2023-12-11 15:56 ` cvs-commit at gcc dot gnu.org
2023-12-11 15:57 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).