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

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|target                      |middle-end
   Last reconfirmed|                            |2026-08-28
             Status|UNCONFIRMED                 |NEW
           Keywords|testsuite-fail              |
     Ever confirmed|0                           |1

--- Comment #2 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
The bug is in the middle end as it sets up arguments in main.
The code in the previous post has been compiled with

$ avr-gcc pr127098.c -S -Os -dp -da -mmcu=atmega128

The problem is already there in pr127098.c.276r.vregs

;; Function main (main, funcdef_no=1, decl_uid=2030, cgraph_uid=3,
symbol_order=2) (executed once)

...
(note 3 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
(note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)

;; SP -= 16 makes space for argument u.
(insn 5 2 6 2 (set (reg/f:HI 32 __SP_L__)
        (plus:HI (reg/f:HI 32 __SP_L__)
            (const_int -16 [0xfffffffffffffff0]))) "pr127098.c":19:3 194
{*addhi3_split}
     (expr_list:REG_ARGS_SIZE (const_int 16 [0x10])
        (nil)))

;; QI:45 = u[0]
(insn 6 5 7 2 (set (reg:QI 45)
        (mem/c:QI (symbol_ref:HI ("u") [flags 0x2]  <var_decl # u>) [0 u+0 S1
A128])) "pr127098.c":19:3 113 {movqi_insn_split}
     (nil))

;; BUG; *(SP+16) = QI:45 where the correct location is *(SP+1).
(insn 7 6 8 2 (set (mem:QI (plus:HI (reg/f:HI 32 __SP_L__)
                (const_int 16 [0x10])) [0  S1 A128])
        (reg:QI 45)) "pr127098.c":19:3 113 {movqi_insn_split}
     (nil))

What does NOT HELP is to, in avr.h

#define STACK_ALIGNMENT_NEEDED 0

What's really awkward is the A128 alignment to 32 bytes for which there is no
request anywhere in the avr backend.

Reply via email to