From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BFBC93972838; Fri, 26 Feb 2021 12:51:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFBC93972838 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/98973] [11 regression] Wrong code with gcse store motion pass Date: Fri, 26 Feb 2021 12:51:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Feb 2021 12:51:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98973 --- Comment #9 from Richard Biener --- Btw, this is likely a latent issue, the store-motion code didn't change sin= ce ages and the bisected rev. likely just changed the input to the pass. So the dump difference is -(note 76 75 217 19 [bb 19] NOTE_INSN_BASIC_BLOCK) -(insn 217 76 78 19 (set (reg:SI 3 %r3 [133]) - (reg:SI 2 %r2 [orig:69 ivtmp.24+4 ] [69])) "t.c":11:19 1467 {*movsi_zarch} - (nil)) -(insn 78 217 218 19 (parallel [ - (set (reg:SI 3 %r3 [133]) - (plus:SI (reg:SI 3 %r3 [133]) - (const_int -1 [0xffffffffffffffff]))) - (clobber (reg:CC 33 %cc)) - ]) "t.c":11:19 1821 {*addsi3} - (nil)) -(insn 218 78 79 19 (set (mem/c:SI (reg/f:DI 8 %r8 [103]) [1 c+0 S4 A32]) - (reg:SI 3 %r3 [133])) "t.c":11:19 1467 {*movsi_zarch} - (nil)) -(insn 79 218 83 19 (parallel [ - (set (reg:DI 2 %r2 [orig:69 ivtmp.24 ] [69]) - (plus:DI (reg:DI 2 %r2 [orig:69 ivtmp.24 ] [69]) +(note 76 75 79 19 [bb 19] NOTE_INSN_BASIC_BLOCK) +(insn 79 76 83 19 (parallel [ + (set (reg:DI 3 %r3 [orig:69 ivtmp.24 ] [69]) + (plus:DI (reg:DI 3 %r3 [orig:69 ivtmp.24 ] [69]) (const_int -1 [0xffffffffffffffff]))) (clobber (reg:CC 33 %cc)) ]) "t.c":11:12 1820 {*adddi3} (nil)) (insn 83 79 84 19 (set (reg:CCS 33 %cc) - (compare:CCS (reg:SI 2 %r2 [orig:69 ivtmp.24+4 ] [69]) + (compare:CCS (reg:SI 3 %r3 [orig:69 ivtmp.24+4 ] [69]) (const_int 2 [0x2]))) "t.c":11:12 1415 {*cmpsi_ccs} where you can see that %r2 is no longer decremented but the store (sunk) after the loop still uses %r2: (insn 175 105 218 23 (set (mem/c:SI (reg/f:DI 8 %r8 [103]) [1 c+0 S4 A32]) (reg:SI 2 %r2 [orig:110 c ] [110])) 1467 {*movsi_zarch} (nil)) -- scanning new insn with uid =3D 175. STORE_MOTION insert store at start of BB 26: (insn 175 105 0 26 (set (mem/c:SI (reg/f:DI 103) [1 c+0 S4 A32]) (reg:SI 110 [ c ])) -1 (nil)) I'll note the gcse dumps are after RA but the store-motion dump is pre-RA.=