On 1/8/25 1:53 PM, H.J. Lu wrote:
Skip extension on stack pointer since we can't turn

(insn 27 26 139 2 (parallel [
             (set (reg/f:SI 7 sp)
                 (plus:SI (reg/f:SI 7 sp)
                     (const_int 16 [0x10])))
             (clobber (reg:CC 17 flags))
         ]) "x.ii":14:17 discrim 1 283 {*addsi_1}
      (expr_list:REG_ARGS_SIZE (const_int 0 [0])
         (nil)))
...
(insn 43 125 74 2 (set (reg/f:DI 6 bp [145])
         (zero_extend:DI (reg/f:SI 7 sp))) "x.ii":15:9 175 {*zero_extendsidi2}
      (nil))

into

(insn 27 26 155 2 (parallel [
             (set (reg:DI 6 bp)
                 (zero_extend:DI (plus:SI (reg/f:SI 7 sp)
                         (const_int 16 [0x10]))))
             (clobber (reg:CC 17 flags))
         ]) "x.ii":14:17 discrim 1 296 {addsi_1_zext}
      (expr_list:REG_ARGS_SIZE (const_int 0 [0])
         (nil)))
(insn 155 27 139 2 (set (reg:DI 7 sp)
         (reg:DI 6 bp)) "x.ii":14:17 discrim 1 -1
      (nil))

without updating stack frame info.

gcc/

        PR rtl-optimization/118266
        * ree.cc (add_removable_extension): Skip extension on stack
        pointer.

gcc/testsuite/

        PR rtl-optimization/118266
        * gcc.target/i386/pr118266.c: New test.
Presumably there were no other uses of sp?

Rather than special casing sp, it seems to me we should probably do this for any fixed register.

OK with that change.

jeff

Reply via email to