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

            Bug ID: 106550
           Summary: [rs6000] sub-optimal constant generation
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: guojiufu at gcc dot gnu.org
  Target Milestone: ---

There is 'pli' which supports a 34bits immediate, so to generate a 64bits
constant we just need 3 instructions at most.

void
foo (unsigned long long *a)
{
  *a = 0x020805006106003;
}

On the trunk, below asm is generated:

        .file   "test.c"
        .machine power10
        .abiversion 2
        .section        ".text"
        .align 2
        .p2align 4,,15
        .globl foo
        .type   foo, @function
foo:
.LFB0:
        .cfi_startproc
        .localentry     foo,1
        lis 9,0x20
        ori 9,9,0x8050
        sldi 9,9,32
        oris 9,9,0x610
        ori 9,9,0x6003
        std 9,0(3)
        blr
        .long 0
        .byte 0,0,0,0,0,0,0,0
        .cfi_endproc
.LFE0:
        .size   foo,.-foo
        .ident  "GCC: (GNU) 13.0.0 20220729 (experimental)"
        .section        .note.GNU-stack,"",@progbits


The compiling command: gcc -O2 -std=c99 test.c -S -mcpu=power10

Reply via email to