From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4DFB4385E037; Wed, 27 Mar 2024 17:51:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DFB4385E037 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711561860; bh=VQJ8pn6gkJNxHXGJJwQxCrLFUJbUMnJxiD7DoM2sQZo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YdHvl56fdSL+5uuMuKOZz135k8+jrqvUliZAtHvlfZOmSsnfyq2Ue4CRYdJa7TXWj 9U6OXheleNBGOKcCNKT+nwoRNWbEjPypPpkWd++bEq9+9BsYt4WBScpSTf2xLm/oGz zUvnIlk6DkcrG9Cf8+kJFgb8Lp6hkakIAgqEDl0k= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/93565] [11/12/13/14 regression] Combine duplicates instructions Date: Wed, 27 Mar 2024 17:50:58 +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: 10.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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: 11.5 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D93565 --- Comment #29 from Andrew Pinski --- Looking back at this one, I (In reply to Wilco from comment #8) > Here is a much simpler example: >=20 > void f (int *p, int y) > { > int a =3D y & 14; > *p =3D a | p[a]; > } After r14-9692-g839bc42772ba7af66af3bd16efed4a69511312ae, we now get: f: .LFB0: .cfi_startproc and w2, w1, 14 mov x1, x2 ldr w2, [x0, x2, lsl 2] orr w1, w2, w1 str w1, [x0] ret .cfi_endproc There is an extra move still but the duplicated and is gone. (with -frename-registers added, the move is gone as REE is able to remove the zero extend but then there is a life range conflict so can't remove the move too= ). So maybe this should be closed as fixed for GCC 14 and the cost changes for= clz reverted. ``` Trying 7 -> 9: 7: r105:SI=3Dr115:SI&0xe REG_DEAD r115:SI 9: r110:DI=3Dzero_extend(r105:SI) Failed to match this instruction: (parallel [ (set (reg:DI 110 [ _1 ]) (and:DI (subreg:DI (reg:SI 115) 0) (const_int 14 [0xe]))) (set (reg/v:SI 105 [ a ]) (and:SI (reg:SI 115) (const_int 14 [0xe]))) ]) Failed to match this instruction: (parallel [ (set (reg:DI 110 [ _1 ]) (and:DI (subreg:DI (reg:SI 115) 0) (const_int 14 [0xe]))) (set (reg/v:SI 105 [ a ]) (and:SI (reg:SI 115) (const_int 14 [0xe]))) ]) Successfully matched this instruction: (set (reg/v:SI 105 [ a ]) (and:SI (reg:SI 115) (const_int 14 [0xe]))) Successfully matched this instruction: (set (reg:DI 110 [ _1 ]) (and:DI (subreg:DI (reg:SI 115) 0) (const_int 14 [0xe]))) allowing combination of insns 7 and 9 original costs 4 + 4 =3D 8 replacement costs 4 + 4 =3D 8 i2 didn't change, not doing this ```=