From patchwork Tue Feb 14 10:08:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 727750 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 3vMyn36rKHz9ryZ for ; Tue, 14 Feb 2017 21:08:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TEaatRIM"; 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 :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=ccT7KBdi620nPwRrD5tSNJdfBAS1020UPSwS/d83q4x mbT7v4SmC+9p3t9MeNYVabTFtmgxUCG7+LW+Msewh0pdOVKZQvWvbFxRZu/pI/C0 BPRBs5nErJepeKB1e4ZicH99VkfW0Fk9kw3Nmd5kp5Ko5ochAqK3t0slrICEtY/I = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=PPvPgd/b5qIx2IGce04KFTcFhvo=; b=TEaatRIMIz06vBYxk TstXT/eGxDLTgR7iIdkS6PnmrUkfl4qxq0lTRVjYD/hgr/uuOgkCPvQn36FzyCH4 HhHlEBq4+0kIH2bDU996CG/0djbBDfvASTpbtlx/o8bMLEqo1bebAxG4wUNWDnKO Vp8bR5wfxbr9ySn0DYg8n8c/Qs= Received: (qmail 106787 invoked by alias); 14 Feb 2017 10:08:44 -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 105239 invoked by uid 89); 14 Feb 2017 10:08:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BRBL_LASTEXT, RCVD_IN_XBL, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=Hx-spam-relays-external:217.140.101.70, H*MI:foss, HX-HELO:foss.arm.com, Hx-languages-length:2161 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Feb 2017 10:08:34 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 54D2CCF2; Tue, 14 Feb 2017 02:08:32 -0800 (PST) Received: from [10.2.207.77] (e100706-lin.cambridge.arm.com [10.2.207.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 85D573F534; Tue, 14 Feb 2017 02:08:31 -0800 (PST) Message-ID: <58A2D71E.9080407@foss.arm.com> Date: Tue, 14 Feb 2017 10:08:30 +0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches CC: Marcus Shawcroft , Richard Earnshaw , James Greenhalgh Subject: [PATCH][AArch64] PR rtl-optimization/68664 Implement TARGET_SCHED_CAN_SPECULATE_INSN hook Hi all, Following up from Segher's patch here is the aarch64 implementation of the new hook. It forbids speculation of the integer and floating-point division instructions as well as the square-root instructions. With this patch the fsqrt is not speculated and the preformance on the code in the PR is improved 3x on a Cortex-A53. Bootstrapped and tested on aarch64-none-linux-gnu. Ok for trunk? Thanks, Kyrill 2016-02-14 Kyrylo Tkachov PR rtl-optimization/68664 * config/aarch64/aarch64.c (aarch64_sched_can_speculate_insn): New function. (TARGET_SCHED_CAN_SPECULATE_INSN): Define. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index eab719d076358f01023cf8b2a37d3c8edd8d8f1f..f72e4c4423d28af66f3bd8068eeb83060d541839 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -14750,6 +14750,35 @@ aarch64_excess_precision (enum excess_precision_type type) return FLT_EVAL_METHOD_UNPREDICTABLE; } +/* Implement TARGET_SCHED_CAN_SPECULATE_INSN. Return true if INSN can be + scheduled for speculative execution. Reject the long-running division + and square-root instructions. */ + +static bool +aarch64_sched_can_speculate_insn (rtx_insn *insn) +{ + switch (get_attr_type (insn)) + { + case TYPE_SDIV: + case TYPE_UDIV: + case TYPE_FDIVS: + case TYPE_FDIVD: + case TYPE_FSQRTS: + case TYPE_FSQRTD: + case TYPE_NEON_FP_SQRT_S: + case TYPE_NEON_FP_SQRT_D: + case TYPE_NEON_FP_SQRT_S_Q: + case TYPE_NEON_FP_SQRT_D_Q: + case TYPE_NEON_FP_DIV_S: + case TYPE_NEON_FP_DIV_D: + case TYPE_NEON_FP_DIV_S_Q: + case TYPE_NEON_FP_DIV_D_Q: + return false; + default: + return true; + } +} + /* Target-specific selftests. */ #if CHECKING_P @@ -15138,6 +15167,9 @@ aarch64_libgcc_floating_mode_supported_p #define TARGET_USE_BY_PIECES_INFRASTRUCTURE_P \ aarch64_use_by_pieces_infrastructure_p +#undef TARGET_SCHED_CAN_SPECULATE_INSN +#define TARGET_SCHED_CAN_SPECULATE_INSN aarch64_sched_can_speculate_insn + #undef TARGET_CAN_USE_DOLOOP_P #define TARGET_CAN_USE_DOLOOP_P can_use_doloop_if_innermost