From patchwork Thu Aug 22 15:53:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 1151670 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-507534-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=foss.arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="mjWeddU8"; dkim-atps=neutral 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 46Dpx731dHz9sN4 for ; Fri, 23 Aug 2019 01:54:03 +1000 (AEST) 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=glunyUiZOlZmgFEddTxt+fG4PzikqlDQfMiE33cfGlJzSMNVjA i2i8JHjBwj3dFDClFSOVDIhasF4ZgCECkrHI7Ys4ClscvpVfvLbOfkXLhvEmZvyQ +x0rBXu5xEjKUcrFrJDxtIHLBu41pueLg8XKHLoJ7WEZ5k1gVDq8gkcIE= 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=1e4GGeJ1bybqzvhM1k6nD25Ouy4=; b=mjWeddU8dZi6+U71mLZD OfHEhFc7F/UjEVAkuwr8Hy51M2uJt6e8XEcWIsJ4+T1xIsWraW3beOwx6ITXehKO hLB3t/FniWCi2/pfJkR0EZcwKuhgbTvdvrJVXCBu3xxJVoTjJM4l44jzURBsO+jL 621blkx/3mD6P2tAv19xp1U= Received: (qmail 109471 invoked by alias); 22 Aug 2019 15:53:56 -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 109396 invoked by uid 89); 22 Aug 2019 15:53:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=H*M:5594, H*MI:5594, arm_acleh, UD:arm_acle.h X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Aug 2019 15:53:50 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BE29E337 for ; Thu, 22 Aug 2019 08:53:48 -0700 (PDT) Received: from [10.2.206.47] (e120808-lin.cambridge.arm.com [10.2.206.47]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 84B713F718 for ; Thu, 22 Aug 2019 08:53:48 -0700 (PDT) To: "gcc-patches@gcc.gnu.org" From: Kyrill Tkachov Subject: [PATCH][arm][committed] Fix use of CRC32 intrinsics with Armv8-a and hard-float Message-ID: Date: Thu, 22 Aug 2019 16:53:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 Hi all, We currently have a nasty error when trying to use the __crc* intrinsics with an -mfloat-abi=hard. That is because the target pragma guarding them uses armv8-a+crc that does not include fp by default. So we get errors like: error: '-mfloat-abi=hard': selected processor lacks an FPU This patch fixes that by using an FP-enabled arch target pragma to guard these intrinsics when floating-point is available. That way both the softfloat and hardfloat variants work. Bootstrapped and tested on arm-none-linux-gnueabihf. Committing to trunk. Will backport to branches later. Thanks, Kyrill 2019-08-22  Kyrylo Tkachov     * config/arm/arm_acle.h: Use arch=armv8-a+crc+simd pragma for CRC32     intrinsics if __ARM_FP.     Use __ARM_FEATURE_CRC32 ifdef guard. 2019-08-22  Kyrylo Tkachov     * gcc.target/arm/acle/crc_hf_1.c: New test. diff --git a/gcc/config/arm/arm_acle.h b/gcc/config/arm/arm_acle.h index 2c7acc698ea50e0cd539a7d9647498746cd1536f..6857ab1787df0ffa672e5078e5a0b9c9cc52e695 100644 --- a/gcc/config/arm/arm_acle.h +++ b/gcc/config/arm/arm_acle.h @@ -174,8 +174,12 @@ __arm_mrrc2 (const unsigned int __coproc, const unsigned int __opc1, #endif /* (!__thumb__ || __thumb2__) && __ARM_ARCH >= 4. */ #pragma GCC push_options -#if __ARM_ARCH >= 8 +#ifdef __ARM_FEATURE_CRC32 +#ifdef __ARM_FP +#pragma GCC target ("arch=armv8-a+crc+simd") +#else #pragma GCC target ("arch=armv8-a+crc") +#endif __extension__ static __inline uint32_t __attribute__ ((__always_inline__)) __crc32b (uint32_t __a, uint8_t __b) @@ -235,7 +239,7 @@ __crc32cd (uint32_t __a, uint64_t __b) } #endif -#endif /* __ARM_ARCH >= 8. */ +#endif /* __ARM_FEATURE_CRC32 */ #pragma GCC pop_options #ifdef __cplusplus diff --git a/gcc/testsuite/gcc.target/arm/acle/crc_hf_1.c b/gcc/testsuite/gcc.target/arm/acle/crc_hf_1.c new file mode 100644 index 0000000000000000000000000000000000000000..e6cbfc0b33e56e4275b96978ca1823d7682792fb --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/crc_hf_1.c @@ -0,0 +1,14 @@ +/* Test that using an Armv8-a hard-float target doesn't + break CRC intrinsics. */ + +/* { dg-do compile } */ +/* { dg-require-effective-target arm_hard_vfp_ok } */ +/* { dg-options "-mfloat-abi=hard -march=armv8-a+simd+crc" } */ + +#include + +uint32_t +foo (uint32_t a, uint32_t b) +{ + return __crc32cw (a, b); +}