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

            Bug ID: 128555
           Summary: [17 Regression] RISC-V: missed sh3add for addition of
                    0x180000000
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yuki.tanaka at defaultcase dot de
  Target Milestone: ---

#include <stdint.h>

uint64_t a(uint64_t x)
{
  return x + 0x180000000;
}

With -O2 -march=rv64gc_zba_zbb, GCC 16.1 emits:
a:
        li      a5,805306368
        sh3add  a0,a5,a0
        ret

Trunk instead emits:
a:
        li      a5,3
        slli    t0,a5,31
        add     a0,a0,t0
        ret

GCC 16.1 uses sh3add to combine the shift and addition. Trunk no longer does
so.

Compiler Explorer:
https://godbolt.org/z/bf3r3W5YP
  • [Bug target/128555] New: [1... yuki.tanaka at defaultcase dot de via Gcc-bugs

Reply via email to