From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A5BD43858407; Thu, 20 Jan 2022 17:27:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5BD43858407 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/101885] [10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu Date: Thu, 20 Jan 2022 17:27: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.2.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned 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: Thu, 20 Jan 2022 17:27:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101885 --- Comment #8 from Jakub Jelinek --- We have: Trying 17 -> 130: 17: {r124:QI=3Dr143:QI&r145:QI;clobber flags:CC;} REG_DEAD r145:QI REG_DEAD r143:QI REG_UNUSED flags:CC 130: flags:CCZ=3Dcmp(r124:QI,0) Successfully matched this instruction: (parallel [ (set (reg:CCZ 17 flags) (compare:CCZ (and:QI (reg:QI 143) (reg:QI 145)) (const_int 0 [0]))) (set (reg:QI 124 [ _199 ]) (and:QI (reg:QI 143) (reg:QI 145))) ]) That merged what we wanted, nice! And then the wrong: Trying 130 -> 132: 130: {flags:CCZ=3Dcmp(r143:QI&r145:QI,0);r124:QI=3Dr143:QI&r145:QI;} REG_DEAD r143:QI REG_DEAD r145:QI 132: r82:QI=3D{(flags:CCZ!=3D0)?r124:QI:r152:QI} REG_DEAD r152:QI REG_DEAD r124:QI REG_EQUAL {(flags:CCZ!=3D0)?r124:QI:0} Failed to match this instruction: (parallel [ (set (reg:QI 82 [ b_lsm_flag.26 ]) (and:QI (reg:QI 143) (reg:QI 145))) (set (reg:CCZ 17 flags) (compare:CCZ (and:QI (reg:QI 143) (reg:QI 145)) (const_int 0 [0]))) ]) Failed to match this instruction: (parallel [ (set (reg:QI 82 [ b_lsm_flag.26 ]) (and:QI (reg:QI 143) (reg:QI 145))) (set (reg:CCZ 17 flags) (compare:CCZ (and:QI (reg:QI 143) (reg:QI 145)) (const_int 0 [0]))) ]) Successfully matched this instruction: (set (reg:CCZ 17 flags) (compare:CCZ (and:QI (reg:QI 143) (reg:QI 145)) (const_int 0 [0]))) Successfully matched this instruction: (set (reg:QI 82 [ b_lsm_flag.26 ]) (and:QI (reg:QI 143) (reg:QI 145))) I guess it would be fine if (reg 17 flags) didn't have other users (in insn= 135 in particular). The failed match attempt (parallel [ (set (reg:QI 82 [ b_lsm_flag.26 ]) (and:QI (reg:QI 143) (reg:QI 145))) (set (reg:CCZ 17 flags) (compare:CCZ (and:QI (reg:QI 143) (reg:QI 145)) (const_int 0 [0]))) ]) actually looks almost good, except that it would need to try them in the ot= her order in the parallel. I must say I forgot whether the flags first then operation ordering is now canonical everywhere, or whether some backends want one and others another = one. But I vaguely remember there are various passes that only work with the ordering x86 has.=