From patchwork Fri Apr 27 13:30:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 155479 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 564FCB6FA2 for ; Fri, 27 Apr 2012 23:30:45 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1336138246; h=Comment: DomainKey-Signature:Received:Received:Received:Received:From:To: Cc:Subject:Date:Message-Id:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=XQB0x/uuiZO04j5HpgStwWuThFE=; b=K6WEA8dAftlp/30 oozlfu4UFMmFcvz27AoJqbS0+7lmIImkpMt+XwObzy2iBmr9vvDAIp2wcDyGD1Yg edf0jIWwCoJARQOEQERJpNGcAXdAdn//TLjJ6TtM+HeZp5jSVwtDDal0hZ0TirtM LeexbtnAfLLV2A6TXDL7IPYTkeuE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:From:To:Cc:Subject:Date:Message-Id:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=DUo5GS42A8g7yoA0lQHag8LWmbCGID5dG6d8iK7N7sBPlG8ZD+MMpPzDYWq2NV NQaL0xLUGv0jGi45jsUDcbo9nMQcoKmK3zp5xunvogX3vzFGzM6iwNypPQfmfgTj 8QdnT7sb3wx1ABh71tIriohQUxTad1gn9m+3tP39L0vsE=; Received: (qmail 22858 invoked by alias); 27 Apr 2012 13:30:41 -0000 Received: (qmail 22848 invoked by uid 22791); 27 Apr 2012 13:30:40 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, TW_LZ, TW_ZC, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Apr 2012 13:30:27 +0000 Received: from bonzini by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1SNlFh-0007Ep-NR; Fri, 27 Apr 2012 09:30:25 -0400 From: Paolo Bonzini To: gcc-patches@gcc.gnu.org Cc: ubizjak@gmail.com Subject: [PATCH] x86: emit tzcnt unconditionally Date: Fri, 27 Apr 2012 15:30:22 +0200 Message-Id: <1335533422-11066-1-git-send-email-bonzini@gnu.org> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org tzcnt is encoded as "rep;bsf" and unlike lzcnt is a drop-in replacement if we don't care about the flags (it has the same semantics for non-zero values). Since bsf is usually slower, just emit tzcnt unconditionally. However, write it as rep;bsf unless -mbmi is in use, to cater for old assemblers. Bootstrapped on a non-BMI x86_64-linux host, regtest in progress. Ok for mainline? Paolo 2012-04-27 Paolo Bonzini * config/i386/i386.md (ctz2): Emit tzcnt (as rep;bsf) instead of bsf. Index: i386/i386.md =================================================================== --- i386/i386.md (revisione 186904) +++ i386/i386.md (copia locale) @@ -12082,14 +12082,15 @@ (define_insn "ctz2" (clobber (reg:CC FLAGS_REG))] "" { + /* tzcnt expands to rep;bsf and we can use it even if !TARGET_BMI. */ if (TARGET_BMI) return "tzcnt{}\t{%1, %0|%0, %1}"; else - return "bsf{}\t{%1, %0|%0, %1}"; + return "rep;bsf{}\t{%1, %0|%0, %1}"; } [(set_attr "type" "alu1") (set_attr "prefix_0f" "1") - (set (attr "prefix_rep") (symbol_ref "TARGET_BMI")) + (set_attr "prefix_rep" "1") (set_attr "mode" "")]) (define_expand "clz2"