From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9128B3840009; Tue, 27 Jul 2021 15:37:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9128B3840009 From: "segher at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/78103] Failure to optimize with __builtin_clzl Date: Tue, 27 Jul 2021 15:37:12 +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: segher at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub 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: Tue, 27 Jul 2021 15:37:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D78103 --- Comment #21 from Segher Boessenkool --- (In reply to Jakub Jelinek from comment #19) > Created attachment 51211 [details] > gcc12-pr78103.patch >=20 > Updated untested patch that uses define_insn_and_split in 2 cases instead= of > the combine splitters so that it can work around the lack of LOG_LINKS. > The patch doesn't do anything with -mlzcnt, even when bsr or bsr + lea wo= uld > be shorter than mov + lzcnt + sub, but I'm afraid we can't do anything ab= out > that, > we've lost information whether it is UB on zero or not with -mlzcnt and f= or > zero input all this is quite unsafe. That patch looks good to me. This is another argument for having some canonical form for stuff with extends, btw (you have a xor of a sign extens= ion with a number that is zero in all bits that are sign copies (incl. the original si= gn) in the extension, so the extension could be pulled to the outside. But the= way things are you really have to handle both xor(sext(x),c) and sext(xor(x,c))= in the machine description, both formulations are allowed, whether or not we t= each simplify-rtx about this (if it doesn't already know :-) )=