From patchwork Thu Apr 27 12:32:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard Earnshaw \(lists\)" X-Patchwork-Id: 98285 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp73144qgf; Thu, 27 Apr 2017 05:32:34 -0700 (PDT) X-Received: by 10.99.97.75 with SMTP id v72mr5596210pgb.76.1493296353929; Thu, 27 Apr 2017 05:32:33 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w28si2599868pfk.227.2017.04.27.05.32.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Apr 2017 05:32:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-452288-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-452288-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-452288-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=BhIAimCXvH9dx2k+/RPU0F3GlSC1DozTPMtGAnecJr9aF/ArcC j80bb3YFB3VYhe6pbNB2bSwWhGjDfTTOznNUrZU/Gek/ZDNo3vGbsJzMEALucr0R +dxa/XMyL8MPxPJjflbrNH+UDqqe1hCxTX1VUb8kB76k0ZDWfULI/pn0s= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=SxrC1oYhPA8eqC+Q4Kae9XTEFEo=; b=YKFXn5dZ6hrLq1WJGJgl gbAJbztkBE1U/8O8hJTJCrMh89A+xx2+Qv6gwFEPg+bmYZZYVCSws+jRrHT17MGp QWJL+M7oR8+MXOeh/SGSi3N27LuE3EPUOS8gSNavwBc8pW0kNOPCpdhQwlZTRG02 ZwfMjVxM49zLeTXsVLdBcAU= Received: (qmail 61649 invoked by alias); 27 Apr 2017 12:32:15 -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 61636 invoked by uid 89); 27 Apr 2017 12:32:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=completed 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; Thu, 27 Apr 2017 12:32:12 +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 32C751650; Thu, 27 Apr 2017 05:32:13 -0700 (PDT) Received: from e105689-lin.cambridge.arm.com (e105689-lin.cambridge.arm.com [10.2.207.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 915683F3E1; Thu, 27 Apr 2017 05:32:12 -0700 (PDT) To: gcc-patches , Jakub Jelinek From: "Richard Earnshaw (lists)" Subject: [AArch64] Fix for gcc-7 regression PR 80530 Message-ID: <28052a23-3c02-24f6-e699-1f29b0634520@arm.com> Date: Thu, 27 Apr 2017 13:32:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 This patch fixes the regression caused by the changes to add square root estimation when compiling for xgene-1 or exynos-m1 targets. The issue is that the expand path for the reciprocal estimate square root pattern assumes that pattern cannot fail once it has been decided that this expansion path is available, but because the logic deep inside aarch64_emit_approx_sqrt() differs from use_rsqrt_p() the two disagree as to what is safe. This patch refactors the logic to ensure that we cannot unknowingly make different choices here. Bootstrap/testing completed ok. I'll apply this to trunk. Jakub: Are we having an RC2? If so, is this ok for the gcc-7 branch? PR target/80530 * config/aarch64/aarch64.c (aarch64_emit_approx_sqrt): Ensure that the logic for permitting reciprocal estimates matches that in use_rsqrt_p. R. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 1e58e9d..6ef49da 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -7971,33 +7971,40 @@ aarch64_emit_approx_sqrt (rtx dst, rtx src, bool recp) machine_mode mode = GET_MODE (dst); if (GET_MODE_INNER (mode) == HFmode) - return false; + { + gcc_assert (!recp); + return false; + } - machine_mode mmsk = mode_for_vector - (int_mode_for_mode (GET_MODE_INNER (mode)), - GET_MODE_NUNITS (mode)); - bool use_approx_sqrt_p = (!recp - && (flag_mlow_precision_sqrt - || (aarch64_tune_params.approx_modes->sqrt - & AARCH64_APPROX_MODE (mode)))); - bool use_approx_rsqrt_p = (recp - && (flag_mrecip_low_precision_sqrt - || (aarch64_tune_params.approx_modes->recip_sqrt - & AARCH64_APPROX_MODE (mode)))); + machine_mode mmsk + = mode_for_vector (int_mode_for_mode (GET_MODE_INNER (mode)), + GET_MODE_NUNITS (mode)); + if (!recp) + { + if (!(flag_mlow_precision_sqrt + || (aarch64_tune_params.approx_modes->sqrt + & AARCH64_APPROX_MODE (mode)))) + return false; + + if (flag_finite_math_only + || flag_trapping_math + || !flag_unsafe_math_optimizations + || optimize_function_for_size_p (cfun)) + return false; + } + else + /* Caller assumes we cannot fail. */ + gcc_assert (use_rsqrt_p (mode)); - if (!flag_finite_math_only - || flag_trapping_math - || !flag_unsafe_math_optimizations - || !(use_approx_sqrt_p || use_approx_rsqrt_p) - || optimize_function_for_size_p (cfun)) - return false; rtx xmsk = gen_reg_rtx (mmsk); if (!recp) - /* When calculating the approximate square root, compare the argument with - 0.0 and create a mask. */ - emit_insn (gen_rtx_SET (xmsk, gen_rtx_NEG (mmsk, gen_rtx_EQ (mmsk, src, - CONST0_RTX (mode))))); + /* When calculating the approximate square root, compare the + argument with 0.0 and create a mask. */ + emit_insn (gen_rtx_SET (xmsk, + gen_rtx_NEG (mmsk, + gen_rtx_EQ (mmsk, src, + CONST0_RTX (mode))))); /* Estimate the approximate reciprocal square root. */ rtx xdst = gen_reg_rtx (mode);