From patchwork Mon Aug 24 11:20:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 509992 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A84941402A0 for ; Mon, 24 Aug 2015 21:20:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=UfGs0rZt; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=Bp4HS8GjbOm8aT+7 p3jHF2H+rB6Xzqz0j8tXErAFWLsgHzik77CLWfXbxs3mOZkmS9hFUSnBcLZ3XBOz JHnV0uwPg6IXMpqlJRu/MxhJxIEN0n6ZDoddZ6n+Obm8EHAairoEK+145SUBGAHF MUU16ZlPVuBWiY2m+9d6NF2IJaY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=IMJLLRU2wwzwy8WP0c9MQv vBh68=; b=UfGs0rZtHRAwd1TzrAkUR9rG9JcHJtu1066TvqYrjh7yt50PTTAPAl fU5/NkrmOQfXaAWI7qK+/1lBKmoAzbtrK975xkgBjaly0sbsMe0gPhl9tWSTGDAq nzXhWxz4WA6vL/D10DLk9B4+x2PGRwubZeKoXfbIQ2WVjdoXydn44= Received: (qmail 41550 invoked by alias); 24 Aug 2015 11:20:50 -0000 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 Received: (qmail 41535 invoked by uid 89); 24 Aug 2015 11:20:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Aug 2015 11:20:49 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-25-RquA4ioVQz697PqvFX4Uhg-1; Mon, 24 Aug 2015 12:20:44 +0100 Received: from localhost ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 24 Aug 2015 12:20:43 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Use cbranch optabs in ifcvt.c Date: Mon, 24 Aug 2015 12:20:43 +0100 Message-ID: <87oahx6igk.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: RquA4ioVQz697PqvFX4Uhg-1 Similarly to the patch for cmpstr(n), this patch uses the optabs interface for cbranchcc4 instead of using HAVE_cbranchcc4 directly. I've cached the result in a pass-local variable (valid only for the duration of the pass). The references to incscc and decscc are dead. The only reference to them in the documentation is: Some machines can also perform @code{and} or @code{plus} operations on condition code values with less instructions than the corresponding @samp{cstore@var{mode}4} insn followed by @code{and} or @code{plus}. On those machines, define the appropriate patterns. Use the names @code{incscc} and @code{decscc}, respectively, for the patterns which perform @code{plus} or @code{minus} operations on condition code values. See @file{rs6000.md} for some examples. The GNU Superoptimizer can be used to find such instruction sequences on other machines. which is in tm.texi rather than md.texi. This seems hopelessly out of date, not least because rs6000.md has no incscc or decscc patterns. If the "appropriate patterns" are just combine patterns, perhaps we should just delete the whole paragraph? Tested on x86_64-linux-gnu. OK to install? Thanks, Richard gcc/ * ifcvt.c (HAVE_incscc, HAVE_decscc, HAVE_cbranchcc4): Delete. (have_cbranchcc4): New variable. (cc_in_cond, noce_emit_cmove, noce_get_alt_condition) (noce_get_condition): Use it instead of HAVE_cbranchcc4. (if_convert): Initialize have_cbranchcc4. diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index a46efec..5cf1721 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -55,23 +55,12 @@ #include "shrink-wrap.h" #include "ifcvt.h" -#ifndef HAVE_incscc -#define HAVE_incscc 0 -#endif -#ifndef HAVE_decscc -#define HAVE_decscc 0 -#endif - #ifndef MAX_CONDITIONAL_EXECUTE #define MAX_CONDITIONAL_EXECUTE \ (BRANCH_COST (optimize_function_for_speed_p (cfun), false) \ + 1) #endif -#ifndef HAVE_cbranchcc4 -#define HAVE_cbranchcc4 0 -#endif - #define IFCVT_MULTIPLE_DUMPS 1 #define NULL_BLOCK ((basic_block) NULL) @@ -79,6 +68,9 @@ /* True if after combine pass. */ static bool ifcvt_after_combine; +/* True if the target has the cbranchcc4 optab. */ +static bool have_cbranchcc4; + /* # of IF-THEN or IF-THEN-ELSE blocks we looked at */ static int num_possible_if_blocks; @@ -1014,7 +1006,7 @@ noce_emit_move_insn (rtx x, rtx y) static rtx cc_in_cond (rtx cond) { - if (HAVE_cbranchcc4 && cond + if (have_cbranchcc4 && cond && GET_MODE_CLASS (GET_MODE (XEXP (cond, 0))) == MODE_CC) return XEXP (cond, 0); @@ -1557,7 +1549,7 @@ noce_emit_cmove (struct noce_if_info *if_info, rtx x, enum rtx_code code, if (! general_operand (cmp_a, GET_MODE (cmp_a)) || ! general_operand (cmp_b, GET_MODE (cmp_b))) { - if (!(HAVE_cbranchcc4) + if (!have_cbranchcc4 || GET_MODE_CLASS (GET_MODE (cmp_a)) != MODE_CC || cmp_b != const0_rtx) return NULL_RTX; @@ -2052,7 +2044,7 @@ noce_get_alt_condition (struct noce_if_info *if_info, rtx target, } cond = canonicalize_condition (if_info->jump, cond, reverse, - earliest, target, HAVE_cbranchcc4, true); + earliest, target, have_cbranchcc4, true); if (! cond || ! reg_mentioned_p (target, cond)) return NULL; @@ -2544,7 +2536,7 @@ noce_get_condition (rtx_insn *jump, rtx_insn **earliest, bool then_else_reversed /* Otherwise, fall back on canonicalize_condition to do the dirty work of manipulating MODE_CC values and COMPARE rtx codes. */ tmp = canonicalize_condition (jump, cond, reverse, earliest, - NULL_RTX, HAVE_cbranchcc4, true); + NULL_RTX, have_cbranchcc4, true); /* We don't handle side-effects in the condition, like handling REG_INC notes and making sure no duplicate conditions are emitted. */ @@ -4645,6 +4637,8 @@ if_convert (bool after_combine) /* Record whether we are after combine pass. */ ifcvt_after_combine = after_combine; + have_cbranchcc4 = (direct_optab_handler (cbranch_optab, CCmode) + != CODE_FOR_nothing); num_possible_if_blocks = 0; num_updated_if_blocks = 0; num_true_changes = 0;