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

            Bug ID: 88311
           Summary: mlongcall indirections are optimised away
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iains at gcc dot gnu.org
  Target Milestone: ---

For m32 PowerPC (at least for m32 on powerpc64-linux-gnu).

OK:

$ ./gcc/xgcc -Bgcc hello.c -mlongcall -dp -S -m32
[iains@gcc1-power7 bld-patched]$ more hello.s
        .file   "hello.c"
        .machine power4
        .section        ".text"
        .section        .rodata
        .align 2
.LC0:
        .string "here we are"
        .section        ".text"
        .align 2
        .globl main
        .type   main, @function
main:
.LFB0:
        .cfi_startproc
        stwu 1,-16(1)    # 22   [c=4 l=4]  movsi_update/1
        .cfi_def_cfa_offset 16
        mflr 0           # 23   [c=4 l=4]  *movsi_internal1/20
        stw 0,20(1)      # 24   [c=4 l=4]  *movsi_internal1/5
        stw 31,12(1)     # 25   [c=4 l=4]  *movsi_internal1/5
        .cfi_offset 65, 4
        .cfi_offset 31, -4
        mr 31,1          # 26   [c=4 l=4]  *movsi_internal1/0
        .cfi_def_cfa_register 31
        lis 9,.LC0@ha    # 5    [c=4 l=4]  elf_high
        la 3,.LC0@l(9)   # 6    [c=4 l=4]  elf_low
        lis 9,puts@ha    # 7    [c=4 l=4]  elf_high
        la 9,puts@l(9)   # 8    [c=4 l=4]  elf_low
        mtctr 9          # 9    [c=4 l=4]  *movsi_internal1/21
        bctrl            # 10   [c=4 l=4] 
*call_value_indirect_nonlocal_sysvsi/0
        li 9,0           # 11   [c=4 l=4]  *movsi_internal1/8
        mr 3,9           # 18   [c=4 l=4]  *movsi_internal1/0
        addi 11,31,16    # 29   [c=4 l=4]  *addsi3/1
        lwz 0,4(11)      # 30   [c=8 l=4]  *movsi_internal1/2
        mtlr 0           # 31   [c=4 l=4]  *movsi_internal1/21
        lwz 31,-4(11)    # 32   [c=8 l=4]  *movsi_internal1/2
        .cfi_def_cfa 11, 0
        mr 1,11          # 33   [c=4 l=4]  stack_restore_tie/0
        .cfi_restore 31
        .cfi_def_cfa_register 1
        blr              # 34   [c=4 l=4]  simple_return
        .cfi_endproc
.LFE0:
        .size   main,.-main
        .ident  "GCC: (GNU) 9.0.0 20181203 (experimental) [trunk revision
266733]"
        .section        .note.GNU-stack,"",@progbits

Not OK:

[iains@gcc1-power7 bld-patched]$ ./gcc/xgcc -Bgcc hello.c -mlongcall -dp -S
-m32 -O1
[iains@gcc1-power7 bld-patched]$ more hello.s
        .file   "hello.c"
        .machine power4
        .section        ".text"
        .align 2
        .globl main
        .type   main, @function
main:
.LFB11:
        .cfi_startproc
        stwu 1,-16(1)    # 21   [c=4 l=4]  movsi_update/1
        .cfi_def_cfa_offset 16
        mflr 0           # 22   [c=4 l=4]  *movsi_internal1/20
        stw 0,20(1)      # 23   [c=4 l=4]  *movsi_internal1/5
        .cfi_offset 65, 4
        lis 3,.LC0@ha    # 19   [c=4 l=4]  elf_high
        la 3,.LC0@l(3)   # 7    [c=4 l=4]  elf_low
        bl puts          # 11   [c=4 l=4]  *call_value_nonlocal_sysvsi/0
^^^^ 
        li 3,0           # 16   [c=4 l=4]  *movsi_internal1/8
        lwz 0,20(1)      # 26   [c=8 l=4]  *movsi_internal1/2
        mtlr 0           # 27   [c=4 l=4]  *movsi_internal1/21
        .cfi_restore 65
        addi 1,1,16      # 28   [c=4 l=4]  stack_restore_tie/1
        .cfi_def_cfa_offset 0
        blr              # 29   [c=4 l=4]  simple_return
        .cfi_endproc
.LFE11:
        .size   main,.-main
        .section        .rodata.str1.4,"aMS",@progbits,1
        .align 2
.LC0:
        .string "here we are"
        .ident  "GCC: (GNU) 9.0.0 20181203 (experimental) [trunk revision
266733]"
        .section        .note.GNU-stack,"",@progbits

Reply via email to