[Bug target/81813] Inefficient stack pointer adjustment

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Aug 15 10:07:17 GMT 2021


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-08-15

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So what is happening is reload produces:
(insn 136 135 187 11 (set (reg:DI 0 ax [orig:102 _38 ] [102])
        (mem/v/c:DI (plus:DI (reg/f:DI 7 sp)
                (const_int 32 [0x20])) [2 MEM[(volatile __u64 *)&wait + 24B]+0
S8 A64])) "./include/linux/compiler.h":276 85 {*movdi_internal}
     (nil))
(insn 187 136 138 11 (set (reg:DI 2 cx [124])
        (plus:DI (reg/f:DI 7 sp)
            (const_int 8 [0x8]))) "fs/fs_pin.c":64 218 {*leadi}
     (nil))
(insn 138 187 139 11 (parallel [
            (set (reg/f:DI 1 dx [122])
                (plus:DI (reg:DI 2 cx [124])
                    (const_int 24 [0x18])))
            (clobber (reg:CC 17 flags))
        ]) "fs/fs_pin.c":64 222 {*adddi_1}
     (nil))
(insn 139 138 140 11 (parallel [
            (set (reg/f:DI 7 sp)
                (plus:DI (reg/f:DI 7 sp)
                    (const_int 8 [0x8])))
            (clobber (reg:CC 17 flags))
        ]) "fs/fs_pin.c":64 222 {*adddi_1}
     (expr_list:REG_ARGS_SIZE (const_int 0 [0])
        (nil)))

Notice how cx is being used.

And then post_reload produces:
(insn 187 136 138 11 (set (reg:DI 2 cx [124])
        (plus:DI (reg/f:DI 7 sp)
            (const_int 8 [0x8]))) "fs/fs_pin.c":64 218 {*leadi}
     (nil))
(insn 138 187 139 11 (parallel [
            (set (reg/f:DI 1 dx [122])
                (plus:DI (reg/f:DI 7 sp)
                    (const_int 32 [0x20])))
            (clobber (reg:CC 17 flags))
        ]) "fs/fs_pin.c":64 222 {*adddi_1}
     (nil))
(insn 139 138 140 11 (set (reg/f:DI 7 sp)
        (reg:DI 2 cx [124])) "fs/fs_pin.c":64 85 {*movdi_internal}
     (expr_list:REG_ARGS_SIZE (const_int 0 [0])
        (nil)))

But I don't understand why it did not prop (plus (reg/f:DI 7 sp)           
(const_int 8 [0x8])) into insn 139 and remove insn 187.

I think this is an issue for LRA/IRA really in the first place. We did not need
to push the variable to the stack in the first place as we are going to
Rematerialize the value after the pop anyways.


So Vlad might want to debug this to make sure this is not a latent bug.


More information about the Gcc-bugs mailing list