Question on gcc RTL and scheduling step.

Henri Cloetens
Wed Feb 26 15:10:00 GMT 2020

Hello All,

I have a problem with GCC during scheduling.

The code I have after scheduling is given below (below the text).
What happens, is follows:

1. The epilogue generator emits an instruction "popret_internal" that
     a. Restores R18 in mode DI. (which corresponds to R18 and R19 in 
mode SI)
     b. Does the function return.
2. Then, during scheduling, the compiler shifts an add instruction PAST 
this return
     instruction, which is incorrect, because:
    (a.) The instruction writes R19. (it restores R18 and R19). The 
scheduler should see this.
    (b.) The instruction changes the PC (program counter).
Q. Why is this happening ?. How can I prevent this ?.

Best Regards,


(insn:TI 44 15 18 2 (parallel [
             (parallel [
                     (set (reg/f:SI 31 %r31)
                         (plus:SI (reg/f:SI 31 %r31)
                             (const_int 24 [0x18])))
                     (set (reg:DI 0 %r0)
                         (mem/c:DI (plus:SI (reg/f:SI 31 %r31)
                                 (const_int 16 [0x10])) [2  S8 A64]))
                     (set (reg:DI 18 %r18)
                         (mem/c:DI (plus:SI (reg/f:SI 31 %r31)
                                 (const_int 8 [0x8])) [2  S8 A64]))
             (set (pc)
         ]) "use_manyregs.c":9:1 1 {popret_internal}
(insn:TI 18 44 21 2 (set (reg:SI 21 %r21 [88])
         (plus:SI (reg:SI 19 %r19 [orig:87 b1 ] [87])
             (reg:SI 30 %r30 [orig:75 a1.0_2 ] [75]))) 
"use_manyregs.c":8:10 8 {addsi3_internal}
      (expr_list:REG_DEAD (reg:SI 19 %r19 [orig:87 b1 ] [87])

More information about the Gcc-help mailing list