From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2793 invoked by alias); 23 Aug 2011 22:01:03 -0000 Received: (qmail 2781 invoked by uid 22791); 23 Aug 2011 22:01:02 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Aug 2011 22:00:49 +0000 From: "gpiez at web dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/50168] __builtin_ctz() and intrinsics __bsr(), __bsf() generate suboptimal code on x86_64 Date: Tue, 23 Aug 2011 23:53:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gpiez at web dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg01968.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50168 --- Comment #4 from Gunther Piez 2011-08-23 22:00:31 UTC --- On 23.08.2011 19:58, jakub at gcc dot gnu.org wrote: > While __builtin_c[lt]z* documentation > says that the result is undefined in that case, I wonder if it would be fine > even if long l = (int) __builtin_c[lt]z* (x); gave a value that wasn't actually > sign-extended to 64 bits. So that software operating on the assumption that the value return by __builtin_c[lt]z* is always int, even in the undefined case, would break as soon at it sees a value outside the int range. Which could very well be the case, AFAIK in the zero case the value of the target register is just unchanged. IMHO this is ok, I doubt that such code exists and even if, it is very broken by design :-) Just my 2 cent.