From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5B59A384C003; Mon, 26 Jul 2021 12:11:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B59A384C003 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/78103] Failure to optimize with __builtin_clzl Date: Mon, 26 Jul 2021 12:11:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 6.2.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 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: Mon, 26 Jul 2021 12:11:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D78103 --- Comment #12 from Jakub Jelinek --- If reusing i2dest for the find_split_case is fine (I must say I'm a little = bit worried about uses of the pseudo in debug insns, whether if we reuse it for something else we properly adjust those insns (or reset them)), what the co= de does in the: rtx newdest =3D i2dest; ... /* Get NEWDEST as a register in the proper mode. We have already validated that we can do this. */ if (GET_MODE (i2dest) !=3D split_mode && split_mode !=3D VOIDmode) { if (REGNO (i2dest) < FIRST_PSEUDO_REGISTER) newdest =3D gen_rtx_REG (split_mode, REGNO (i2dest)); else { SUBST_MODE (regno_reg_rtx[REGNO (i2dest)], split_mode); newdest =3D regno_reg_rtx[REGNO (i2dest)]; } } code if the if condition is false, can't it also try to reuse i2dest in the else if (m_split_insn && NEXT_INSN (NEXT_INSN (m_split_insn)) =3D=3D = NULL_RTX && (next_nonnote_nondebug_insn (i2) =3D=3D i3 || !modified_between_p (PATTERN (m_split_insn), i2, i3))) case (if it verifies i2dest doesn't appear anywhere in i2set and i3set) by rewriting the SET_DEST of the i2set and all uses of it in i3set with i2dest= if the mode matches? On the other side the Since nowadays we can create registers during combine just fin= e, we should just create a new one here, not reuse i2dest. */ comment says we should prefer creating new regs. If so, fine, but then we shouldn't just distribute the preexisting i3links, i2links etc., but should= try to create new ones. I see the code does: LOG_LINKS (i3) =3D NULL; REG_NOTES (i3) =3D 0; LOG_LINKS (i2) =3D NULL; REG_NOTES (i2) =3D 0; and then somewhat later distribute_links (i3links); distribute_links (i2links); distribute_links (i1links); distribute_links (i0links); so distributes preexisting log links, but I don't see anything that would similarly handle newly added pseudos from the combine_split_insns, create n= ew log link for that, record_value_for_reg etc.=