From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D9B1C3861855; Thu, 15 Feb 2024 09:43:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9B1C3861855 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707990187; bh=BfRKUXQbITW9JizZEIOfWeL7J7ZFlxOwMU0YojXQI9Q=; h=From:To:Subject:Date:From; b=WSqmtMkkVRarBKt3d4nCPLQFmD5SkIGKKVQdUhM6dafG4XqkdRWs82la/EsIxZvzj dA/gZOa695O5IFzAnSSnx+ZNakVCObb/KBxaO/F3QFSE1ueR8R293c1VdkwLSZDgIC ziOhADhvajlkp3N+0NGIbxsADH0HYfOhNnIDPT4o= From: "gjl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/113927] New: [avr-tiny] Sets up a stack-frame even for trivial code Date: Thu, 15 Feb 2024 09:43:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gjl at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113927 Bug ID: 113927 Summary: [avr-tiny] Sets up a stack-frame even for trivial code Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: gjl at gcc dot gnu.org Target Milestone: --- Code like char func (char c) { return c; } compiles as expected to func: /* prologue: function */ /* frame size =3D 0 */ /* stack size =3D 0 */ .L__stack_usage =3D 0 /* epilogue start */ ret with avr-gcc -S -Os -mmcu=3Dattiny26 -da , but for attiny40 (Reduced Tiny = with 16 GPRs only) the result is: func: push r28 push r29 push __tmp_reg__ in r28,__SP_L__ in r29,__SP_H__ /* prologue: function */ /* frame size =3D 1 */ /* stack size =3D 3 */ .L__stack_usage =3D 3 /* epilogue start */ pop __tmp_reg__ pop r29 pop r28 ret In .asmcons, i.e. just prior to register allocation, the code reads: (insn 13 4 2 2 (set (reg:QI 46) (reg:QI 24 r24 [ c ])) "main.c":2:1 86 {movqi_insn_split} (expr_list:REG_DEAD (reg:QI 24 r24 [ c ]) (nil))) (insn 2 13 3 2 (set (reg/v:QI 44 [ c ]) (reg:QI 46)) "main.c":2:1 86 {movqi_insn_split} (expr_list:REG_DEAD (reg:QI 46) (nil))) (note 3 2 10 2 NOTE_INSN_FUNCTION_BEG) (insn 10 3 11 2 (set (reg/i:QI 24 r24) (reg/v:QI 44 [ c ])) "main.c":4:1 86 {movqi_insn_split} (expr_list:REG_DEAD (reg/v:QI 44 [ c ]) (nil))) (insn 11 10 0 2 (use (reg/i:QI 24 r24)) "main.c":4:1 -1 (nil)) so everything is fine and this PR is not a dup of PR110093. According to Vladimir Makarov, PR110093 is because DFA cannot handle subregs, but the RTL code above does not have subregs. What's the case is that IRA has very high register costs, for example in .ira: Pass 0 for finding pseudo/allocno costs a1 (r46,l0) best NO_REGS, allocno NO_REGS a0 (r44,l0) best NO_REGS, allocno NO_REGS a0(r44,l0) costs: POINTER_X_REGS:65535000 POINTER_Y_REGS:65535000 POINTER_Z_REGS:65535000 BASE_POINTER_REGS:65535000 POINTER_REGS:65535000 SIMPLE_LD_REGS:65535000 GENERAL_REGS:65535000 MEM:3000 whereas the .ira for attiny26 (ordinary core with 32 GPRs): Pass 0 for finding pseudo/allocno costs a0 (r46,l0) best GENERAL_REGS, allocno GENERAL_REGS a0(r46,l0) costs: POINTER_X_REGS:4000 POINTER_Y_REGS:4000 POINTER_Z_REGS:= 4000 BASE_POINTER_REGS:4000 POINTER_REGS:4000 ADDW_REGS:4000 SIMPLE_LD_REGS:4000 LD_REGS:4000 NO_LD_REGS:4000 GENERAL_REGS:4000 MEM:4000 ../../source/gcc-master/configure --target=3Davr --disable-nls --with-dwarf2 --with-gnu-as --with-gnu-ld --disable-shared --enable-languages=3Dc,c++=