From patchwork Wed Jul 17 13:26:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Torbj=C3=B6rn_SVENSSON?= X-Patchwork-Id: 1961625 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foss.st.com header.i=@foss.st.com header.a=rsa-sha256 header.s=selector1 header.b=MG6DUbgP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WPGz91zfBz1ySl for ; Wed, 17 Jul 2024 23:30:44 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 201E5385DDCC for ; Wed, 17 Jul 2024 13:30:43 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by sourceware.org (Postfix) with ESMTPS id 5FDEF3858D34 for ; Wed, 17 Jul 2024 13:30:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5FDEF3858D34 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=foss.st.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5FDEF3858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.132.182.106 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721223023; cv=none; b=UgXIPI8joXfS3AcUevMcSnw0yKP9pdcQsJ4ax/OkyOaYO0pfVygiN4MzczswLqz6fMWO+G6TzRNyGBSuyijOwCDoQ+RcRp8ukmUYgDg7AkcFSYZad1qOMoOKNx9bHIG63IG2JB69/tt/gWJil+FHHQChipfstEx7YSTnspYd5cY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721223023; c=relaxed/simple; bh=vvpZ66o4G75lKFJDPIrDhEpR7fXWcLfqqw4MYEFnLbc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gvCP3Al/CyjNglVNVHT5x8eToHOhTNAYBNB/WGt81inNLn4dao200S6StEDVUH1x98w4ozQrexRY3g6SsugjqNX4Y2wlugwsm1FRVq4DipesaQp0GvrPv+3SlaE9P4xmgFMEp6aZBMrk7/ITFWQhRUgXefL4NOQRbvNk3IzlfgM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0369458.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HBDs2a020678; Wed, 17 Jul 2024 15:30:18 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=selector1; bh=/L4/kjh6ErgiTKdPP6UFPi aPEh6dsFEPAz1RzHlN/To=; b=MG6DUbgPBXTaT1zzdOwE126U7HOxOP1nL0VdjD GzvfC2p3k+jBisaRITb6pdvinqDCPmzZ62M0D0gQe+eixeDapT7LpKhOcHvu58ST fZYJiGo+xRHt3MvmKkOrUogCmfAlKqZlkBNGQ3U7lLHCOjJUnycWRTzL+laTpNUH VOoxmN/sJsuGU/2pho23dkBk4Og4MGg+hll71FA2RkLN8dW7B/i8ATCqgUtplaJH LU/U4m3QY/rJVIr3Bz9EnBuEX7x3uouHvj+HDK//g+Ymt4xIrzmpwr+8ZtayVSl6 2bIc/g8VyRYWpduk5l6MHNq5fD4W8V0fmevvKRhx+rmFgnIQ== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 40dwfkuqxt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 15:30:18 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 591D84002D; Wed, 17 Jul 2024 15:30:11 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 54636223668; Wed, 17 Jul 2024 15:30:00 +0200 (CEST) Received: from jkgcxl0004.jkg.st.com (10.74.22.255) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Wed, 17 Jul 2024 15:29:59 +0200 From: =?utf-8?q?Torbj=C3=B6rn_SVENSSON?= To: CC: , , =?utf-8?q?Torbj?= =?utf-8?q?=C3=B6rn_SVENSSON?= Subject: [PATCH v3] testsuite: Avoid running incompatible Arm tests Date: Wed, 17 Jul 2024 15:26:32 +0200 Message-ID: <20240717132631.3898860-1-torbjorn.svensson@foss.st.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.74.22.255] X-ClientProxiedBy: SHFCAS1NODE2.st.com (10.75.129.73) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-17_08,2024-07-17_02,2024-05-17_01 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Ok for trunk and releases/gcc-14? Changes since v2: - The case when -mfpu and/or -mfloat-abi is defined to an incompatible value. With v3, the defined multilib wins the race and the flag is no longer overridden if set. Changes since v1: - Fixed a regression for armv8l-unknown-linux-gnueabihf reported by Linaro TCWG-CI. --- Overriding the -mpfu and -mfloat-abi might be incompatible with selected multilib. As a result, verify that the current multilib is compatible with the effective target without changing the -mfpu or -mfloat-abi options. gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_effective_target_arm_hard_vfp_ok): Check -mfpu value. (check_effective_target_arm_fp16_ok_nocache): Do not override -mfpu or -mfloat-abi if defined. (check_effective_target_arm_fp16_alternative_ok_nocache): Reuse check_effective_target_arm_fp16_ok. (check_effective_target_arm_fp16_none_ok_nocache): Likewise. (check_effective_target_arm_v8_neon_ok_nocache): Align checks with skeleton from check_effective_target_arm_fp16_ok_nocache. (check_effective_target_arm_neonv2_ok_nocache): Likewise. Signed-off-by: Torbjörn SVENSSON Co-authored-by: Yvan ROUX --- gcc/testsuite/lib/target-supports.exp | 156 +++++++++++++++++++------- 1 file changed, 116 insertions(+), 40 deletions(-) diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index f001c28072f..e0de44872e0 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -4829,6 +4829,7 @@ proc check_effective_target_arm_v8_vfp_ok {} { proc check_effective_target_arm_hard_vfp_ok { } { if { [check_effective_target_arm32] + && ! [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=vfp" }]] && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } { return [check_no_compiler_messages arm_hard_vfp_ok executable { int main() { return 0;} @@ -5405,11 +5406,12 @@ proc check_effective_target_arm_fp16_alternative_ok_nocache { } { # Not supported by the target system. return 0 } + global et_arm_fp16_flags global et_arm_fp16_alternative_flags set et_arm_fp16_alternative_flags "" - if { [check_effective_target_arm32] } { - foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16" - "-mfpu=neon-fp16 -mfloat-abi=softfp"} { + + if { [check_effective_target_arm32] && [check_effective_target_arm_fp16_ok] } { + foreach flags [list "" $et_arm_fp16_flags] { if { [check_no_compiler_messages_nocache \ arm_fp16_alternative_ok object { #if !defined (__ARM_FP16_FORMAT_ALTERNATIVE) || ! (__ARM_FP & 2) @@ -5434,9 +5436,9 @@ proc check_effective_target_arm_fp16_alternative_ok { } { # format. Some multilibs may be incompatible with the options needed. proc check_effective_target_arm_fp16_none_ok_nocache { } { - if { [check_effective_target_arm32] } { - foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16" - "-mfpu=neon-fp16 -mfloat-abi=softfp"} { + global et_arm_fp16_flags + if { [check_effective_target_arm32] && [check_effective_target_arm_fp16_ok] } { + foreach flags [list "" $et_arm_fp16_flags] { if { [check_no_compiler_messages_nocache \ arm_fp16_none_ok object { #if defined (__ARM_FP16_FORMAT_ALTERNATIVE) @@ -5467,23 +5469,55 @@ proc check_effective_target_arm_fp16_none_ok { } { proc check_effective_target_arm_v8_neon_ok_nocache { } { global et_arm_v8_neon_flags set et_arm_v8_neon_flags "" - if { [check_effective_target_arm32] } { - foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} { - if { [check_no_compiler_messages_nocache arm_v8_neon_ok object { - #if __ARM_ARCH < 8 - #error not armv8 or later - #endif - #include "arm_neon.h" - void - foo () - { - __asm__ volatile ("vrintn.f32 q0, q0"); - } - } "$flags -march=armv8-a"] } { - set et_arm_v8_neon_flags $flags - return 1 - } + if { ! [check_effective_target_arm32] } { + return 0; + } + if [check-flags \ + [list "" { *-*-* } { "-mfpu=*" } \ + { "-mfpu=*fp-armv8*" } ]] { + # Multilib flags would override -mfpu. + return 0 + } + if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] { + # Must generate floating-point instructions. + return 0 + } + if [check_effective_target_arm_hf_eabi] { + if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] { + # Use existing -mfpu value and -mfloat-abi value + set et_arm_v8_neon_flags "" + } else { + # Use existing float-abi and force an fpu which supports fp + set et_arm_v8_neon_flags "-mfpu=neon-fp-armv8" + } + return 1; + } + if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] { + if [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "" } ]] { + # The existing -mfpu value and -mfloat-abi value are OK; use them. + set et_arm_v8_neon_flags "" + } else { + # The existing -mfpu value is OK; use it, but add softfp. + set et_arm_v8_neon_flags "-mfloat-abi=softfp" + } + return 1; + } + + # Try adding -mfpu and -mfloat-abi to verify that toolchain supports it + set flags "-mfpu=neon-fp-armv8 -mfloat-abi=softfp" + if { [check_no_compiler_messages_nocache arm_v8_neon_ok object { + #if __ARM_ARCH < 8 + #error not armv8 or later + #endif + #include "arm_neon.h" + void + foo () + { + __asm__ volatile ("vrintn.f32 q0, q0"); } + } "$flags -march=armv8-a"] } { + set et_arm_v8_neon_flags $flags + return 1 } return 0 @@ -5503,21 +5537,53 @@ proc check_effective_target_arm_neonv2_ok_nocache { } { global et_arm_neonv2_flags global et_arm_neon_flags set et_arm_neonv2_flags "" - if { [check_effective_target_arm32] - && [check_effective_target_arm_neon_ok] } { - foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} { - if { [check_no_compiler_messages_nocache arm_neonv2_ok object { - #include "arm_neon.h" - float32x2_t - foo (float32x2_t a, float32x2_t b, float32x2_t c) - { - return vfma_f32 (a, b, c); - } - } "$et_arm_neon_flags $flags"] } { - set et_arm_neonv2_flags [concat $et_arm_neon_flags $flags] - return 1 - } + if { ! [check_effective_target_arm32] || ! [check_effective_target_arm_neon_ok] } { + return 0; + } + if [check-flags \ + [list "" { *-*-* } { "-mfpu=*" } \ + { "-mfpu=*fpv[4-9]*" \ + "-mfpu=*fpv[1-9][0-9]*" "-mfpu=*fp-armv8*" } ]] { + # Multilib flags would override -mfpu. + return 0 + } + if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] { + # Must generate floating-point instructions. + return 0 + } + if [check_effective_target_arm_hf_eabi] { + if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] { + # Use existing -mfpu value and -mfloat-abi value + set et_arm_neonv2_flags "" + } else { + # Use existing float-abi and force an fpu which supports neonv2 + set et_arm_neonv2_flags $et_arm_neon_flags + } + return 1; + } + if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] { + if [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "" } ]] { + # The existing -mfpu value and -mfloat-abi value are OK; use them. + set et_arm_neonv2_flags "" + } else { + # The existing -mfpu value is OK; use it, but add softfp. + set et_arm_neonv2_flags [concat $et_arm_neon_flags "-mfloat-abi=softfp"] + } + return 1; + } + + # Try adding -mfpu and -mfloat-abi to verify that toolchain supports it + set flags "-mfpu=neon-vfpv4 -mfloat-abi=softfp" + if { [check_no_compiler_messages_nocache arm_neonv2_ok object { + #include "arm_neon.h" + float32x2_t + foo (float32x2_t a, float32x2_t b, float32x2_t c) + { + return vfma_f32 (a, b, c); } + } "$et_arm_neon_flags $flags"] } { + set et_arm_neonv2_flags [concat $et_arm_neon_flags $flags] + return 1 } return 0 @@ -5585,13 +5651,23 @@ proc check_effective_target_arm_fp16_ok_nocache { } { return 0 } if [check_effective_target_arm_hf_eabi] { - # Use existing float-abi and force an fpu which supports fp16 - set et_arm_fp16_flags "-mfpu=vfpv4" + if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] { + # Use existing -mfpu value and -mfloat-abi value + set et_arm_fp16_flags "" + } else { + # Use existing float-abi and force an fpu which supports fp16 + set et_arm_fp16_flags "-mfpu=vfpv4" + } return 1; } if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] { - # The existing -mfpu value is OK; use it, but add softfp. - set et_arm_fp16_flags "-mfloat-abi=softfp" + if [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "" } ]] { + # The existing -mfpu value and -mfloat-abi value are OK; use them. + set et_arm_fp16_flags "" + } else { + # The existing -mfpu value is OK; use it, but add softfp. + set et_arm_fp16_flags "-mfloat-abi=softfp" + } return 1; } # Add -mfpu for a VFP fp16 variant since there is no preprocessor