From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4614438346B3; Tue, 10 May 2022 08:24:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4614438346B3 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/104544] [10 Regression] '-fcompare-debug' failure (length) w/ -O2 Date: Tue, 10 May 2022 08:24:19 +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: 12.0 X-Bugzilla-Keywords: compare-debug-failure X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.4 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: Tue, 10 May 2022 08:24:19 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104544 --- Comment #8 from CVS Commits --- The releases/gcc-10 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:de63115b4e819ef0e3cddbeb6ef036e7971b044b commit r10-10684-gde63115b4e819ef0e3cddbeb6ef036e7971b044b Author: Jakub Jelinek Date: Wed Feb 16 14:48:30 2022 +0100 combine: Fix up -fcompare-debug issue in the combiner [PR104544] On the following testcase on aarch64-linux, we behave differently with -g and -g0. The problem is that on: (insn 10011 10010 10012 2 (set (reg:CC 66 cc) (compare:CC (reg:DI 105) (const_int 0 [0]))) "pr104544.c":18:3 407 {cmpdi} (expr_list:REG_DEAD (reg:DI 105) (nil))) (insn 10012 10011 10013 2 (set (reg:SI 109) (eq:SI (reg:CC 66 cc) (const_int 0 [0]))) "pr104544.c":18:3 444 {aarch64_cstoresi} (expr_list:REG_DEAD (reg:CC 66 cc) (nil))) (insn 10013 10012 10016 2 (set (reg:DI 110) (zero_extend:DI (reg:SI 109))) "pr104544.c":18:3 111 {*zero_extendsidi2_aarch64} (expr_list:REG_DEAD (reg:SI 109) (nil))) (insn 10016 10013 10017 2 (parallel [ (set (reg:CC 66 cc) (compare:CC (const_int 0 [0]) (reg:DI 110))) (set (reg:DI 111) (neg:DI (reg:DI 110))) ]) "pr104544.c":18:3 281 {negdi_carryout} (expr_list:REG_DEAD (reg:DI 110) (nil))) ... (debug_insn 6 5 7 2 (var_location:SI y (debug_expr:SI D#5)) "pr104544.c":18:3 -1 (nil)) (debug_insn 7 6 10033 2 (debug_marker) "pr104544.c":11:3 -1 (nil)) (insn 10033 7 10034 2 (set (reg:DI 117 [ _14 ]) (ior:DI (reg:DI 111) (reg:DI 112))) "pr104544.c":11:6 496 {iordi3} (expr_list:REG_DEAD (reg:DI 112) (expr_list:REG_DEAD (reg:DI 111) (nil)))) we successfully split 3 insns into two: Trying 10011, 10013 -> 10016: 10011: cc:CC=3Dcmp(r105:DI,0) REG_DEAD r105:DI 10013: r110:DI=3Dcc:CC=3D=3D0 REG_DEAD cc:CC 10016: {cc:CC=3Dcmp(0,r110:DI);r111:DI=3D-r110:DI;} REG_DEAD r110:DI Failed to match this instruction: (parallel [ (set (reg:CC 66 cc) (compare:CC (reg:DI 105) (const_int 0 [0]))) (set (reg:DI 111) (neg:DI (eq:DI (reg:DI 105) (const_int 0 [0])))) ]) Failed to match this instruction: (parallel [ (set (reg:CC 66 cc) (compare:CC (reg:DI 105) (const_int 0 [0]))) (set (reg:DI 111) (neg:DI (eq:DI (reg:DI 105) (const_int 0 [0])))) ]) Successfully matched this instruction: (set (reg:DI 111) (neg:DI (eq:DI (reg:DI 105) (const_int 0 [0])))) Successfully matched this instruction: (set (reg:CC 66 cc) (compare:CC (reg:DI 105) (const_int 0 [0]))) Successfully matched this instruction: (set (reg:DI 112) (neg:DI (eq:DI (reg:CC 66 cc) (const_int 0 [0])))) allowing combination of insns 10011, 10013 and 10016 original costs 4 + 4 + 4 =3D 16 replacement costs 4 + 4 =3D 12 deferring deletion of insn with uid =3D 10011. but the code that searches forward for insns to update their log links (before the change there is a link from insn 10033 to insn 10016 for pseudo 111) only finds insn 10033 and updates the log link if -g isn't enabled, otherwise it stops earlier because there are debug in= sns in between. So, with -g LOG_LINKS of 10033 isn't updated, points eventually to NOTE_INSN_DELETED and so we do not attempt to combine 10033 with oth= er insns, while with -g0 we do. The following patch fixes that by instead ignoring debug insns during t= he searching. We can still check BLOCK_FOR_INSN (insn) on those, because if we notice DEBUG_INSN in a following basic block, necessarily there w= on't be any further normal insns in the current block after it. 2022-02-16 Jakub Jelinek PR rtl-optimization/104544 * combine.c (try_combine): When looking for insn whose links should be updated from i3 to i2, don't stop on debug insns, ins= tead skip over them. * gcc.dg/pr104544.c: New test. (cherry picked from commit f997eef5654f782bedb985c9285862c4d76b3209)=