From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B23333858D35; Mon, 15 Apr 2024 22:42:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B23333858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713220921; bh=RBmjPLodMWh5XBovInzrl82bnfTKafxXpYd2EchvDBw=; h=From:To:Subject:Date:From; b=oFwgK7uBiPE/c/b0lqB8CiGDSJ4mqFmfqnP40a8ZXvNWSH+cqppJGZsvJpId1iTjR PQshgg+HUechURk9MvAWJX+V0aNhLd5avGvBkyTRUI1RBkeKlJF3Y6AM4614WIBwlQ f+ZBkrp9y0Jk4OG0WDHKcOApFfaZPlLVhh7zjJjI= From: "vineetg at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114729] New: RISC-V SPEC2017 507.cactu excessive spillls with -fschedule-insns Date: Mon, 15 Apr 2024 22:42:00 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vineetg 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 cc target_milestone attachments.created 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=3D114729 Bug ID: 114729 Summary: RISC-V SPEC2017 507.cactu excessive spillls with -fschedule-insns Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: vineetg at gcc dot gnu.org CC: jeffreyalaw at gmail dot com, kito.cheng at gmail dot c= om, rdapp at gcc dot gnu.org Target Milestone: --- Created attachment 57953 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D57953&action=3Dedit spec cactu reduced In RISC-V SPEC runs, Cactu dynamic icounts are worst of all (compared to aarch64 with similar build toggles: -Ofast).=20 As of Upstream commit 3fed1609f610 of 2024-01-31: aarch64: 1,363,212,534,747 vs. risc-v : 2,852,277,890,338=20 There's an existing issue https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D10= 6265 which captures ongoing work to improve the stack/array accesses. However th= at is more of damage control. The root cause happens to be excessive stack spi= lls on RISC-V. Robin noticed these were somehow triggered by first scheduling p= ass. Disabling sched1 with -fno-schedule-insns brings down the total icount to h= alf=20 1,295,520,619,523 which is even slightly better than aarch64, all things considered. I ran a reducer (tracking token sfp in -verbose-asm output) and was able to= get a test which shows a single stack spill (store+load) with default/-fschedule-insns and none with -fno-schedule-insns. It seems sched1 is moving insn around, but the actual spills are generated = by IRA. So this is an interplay of sched1 and IRA. ``` ira New iteration of spill/restore move Changing RTL for loop 2 (header bb6) Changing RTL for loop 1 (header bb4) 26 vs parent 26:Creating newreg=3D246 from oldreg=3D137 25 vs parent 25:Creating newreg=3D247 from oldreg=3D143 11 vs parent 11:Creating newreg=3D248 from oldreg=3D223 16 vs parent 16:Creating newreg=3D249 from oldreg=3D237 Changing RTL for loop 3 (header bb3) 26 vs parent 26:Creating newreg=3D250 from oldreg=3D246 25 vs parent 25:Creating newreg=3D251 from oldreg=3D247 -1 vs parent 11:Creating newreg=3D253 from oldreg=3D248 16 vs parent 16:Creating newreg=3D254 from oldreg=3D249 ... scanning new insn with uid =3D 181. scanning new insn with uid =3D 182. scanning new insn with uid =3D 183. scanning new insn with uid =3D 184. changing bb of uid 194 unscanned insn scanning new insn with uid =3D 185. scanning new insn with uid =3D 186. scanning new insn with uid =3D 187. scanning new insn with uid =3D 188. changing bb of uid 195 unscanned insn ... +++Costs: overall 11650, reg 10680, mem 970, ld 485, st 485, move 1366 +++ move loops 0, new jumps 2 ... (insn 9 104 11 2 (set (reg/f:DI 137 [ r.4_4 ]) (mem/f/c:DI (lo_sum:DI (reg/f:DI 155) (symbol_ref:DI ("r") [flags 0x86]=20=20 )) [4 r+0 S8 A64])) {*movdi_64bit} (expr_list:REG_DEAD (reg/f:DI 155) (expr_list:REG_EQUAL (mem/f/c:DI=20 (symbol_ref:DI ("r") [flags 0x86]=20=20 ) [4 r+0 S8 A64]) (insn 115 165 181 2 (set (reg:DI 245) (const_int 1 [0x1])) {*movdi_64bit} (expr_list:REG_EQUIV (const_int 1 [0x1]) ---- spill code start ----- (insn 181 115 182 2 (set (reg/f:DI 246=20 [orig:137 r.4_4 ] [137]) (reg/f:DI 137 [ r.4_4 ])) {*movdi_64bit} (expr_list:REG_DEAD (reg/f:DI 137 [ r.4_4 ]) (insn 182 181 183 2 (set (reg/f:DI 247=20 [orig:143 w.9_10 ] [143]) (reg/f:DI 143 [ w.9_10 ])) {*movdi_64bit} (expr_list:REG_DEAD (reg/f:DI 143 [ w.9_10 ]) (insn 183 182 184 2 (set (reg:DI 248=20 [orig:223 MEM[(int *)j.15_19 + 4B] ] [223]) (reg:DI 223 [ MEM[(int *)j.15_19 + 4B] ]))=20 {*movdi_64bit} (expr_list:REG_DEAD (reg:DI 223=20 [ MEM[(int *)j.15_19 + 4B] ]) (insn 184 183 174 2 (set (reg:DI 249=20 [orig:237 _38 ] [237]) (reg:DI 237 [ _38 ])) {*movdi_64bit} (expr_list:REG_DEAD (reg:DI 237 [ _38 ]) ---- spill code ----- (jump_insn 174 184 175 2 (set (pc) (label_ref 100)) 350 {jump} (nil) -> 100) (barrier 175 174 196) ---- spill code start ----- (code_label 196 175 195 10 10 (nil) [1 uses]) (note 195 196 189 10 [bb 10] NOTE_INSN_BASIC_BLOCK) (insn 189 195 190 10 (set (reg/f:DI 250=20 [orig:137 r.4_4 ] [137]) (reg/f:DI 246 [orig:137 r.4_4 ] [137]))=20 {*movdi_64bit} (expr_list:REG_DEAD (reg/f:DI 246=20 [orig:137 r.4_4 ] [137]) (insn 190 189 191 10 (set (reg/f:DI 251=20 [orig:143 w.9_10 ] [143]) (reg/f:DI 247 [orig:143 w.9_10 ] [143]))=20 {*movdi_64bit} (expr_list:REG_DEAD (reg/f:DI 247=20 [orig:143 w.9_10 ] [143]) (insn 191 190 192 10 (set (reg/v:DI 252=20 [orig:152 i ] [152]) (reg/v:DI 152 [ i ])) 208 {*movdi_64bit} (expr_list:REG_DEAD (reg/v:DI 152 [ i ]) (insn 192 191 193 10 (set (reg:DI 253=20 [orig:223 MEM[(int *)j.15_19 + 4B] ] [223]) (reg:DI 248 [orig:223=20 MEM[(int *)j.15_19 + 4B] ] [223])) {*movdi_64bit} (expr_list:REG_DEAD (reg:DI 248=20 [orig:223 MEM[(int *)j.15_19 + 4B] ] [223]) (insn 193 192 97 10 (set (reg:DI 254=20 [orig:237 _38 ] [237]) (reg:DI 249 [orig:237 _38 ] [237]))=20 {*movdi_64bit} (expr_list:REG_DEAD (reg:DI 249=20 [orig:237 _38 ] [237]) ---- spill code ----- (code_label 97 193 14 3 3 (nil) [1 uses]) (note 14 97 33 3 [bb 3] NOTE_INSN_BASIC_BLOCK) (insn 17 56 21 3 (set (reg:DF 159 [ l ]) (mem/c:DF (lo_sum:DI (reg/f:DI 234) ```=