From patchwork Fri Nov 27 13:00:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 57367 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1129613lbb; Fri, 27 Nov 2015 05:00:57 -0800 (PST) X-Received: by 10.66.158.129 with SMTP id wu1mr68071059pab.146.1448629256514; Fri, 27 Nov 2015 05:00:56 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u74si8325974pfi.118.2015.11.27.05.00.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Nov 2015 05:00:56 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-415641-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; spf=pass (google.com: domain of gcc-patches-return-415641-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-415641-patch=linaro.org@gcc.gnu.org; dkim=pass header.i=@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 :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=AdKnjI7wH/rLg6GJ3EFVsDEzNkinD4fxiZQEUa5rPPz8gJ ouMEIHcUnIO0k8rz8HhSWw/R/NbBQJhM+1Ee+4LWHbS7dey6CyoNBYvUn0FXWXZK B15w0/gYFQKnuDSQoDj6jt/QHWgiWrenLZIJT3LkFZCxdKaSuiVyerHvpcgmU= 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 :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=za4EPcFv7v6XGXM2kAP9bNzieTU=; b=W2CaxYTK4Ug/iR1faG1i PZ5lm1DUHrT2oqFVKZvnxDueACZziPbwMKva2aewdZPe8hhMDlVgJGytR0iAFle9 HCIZmSGgq12hvBKHWqEGP+apnjrHEAVAHBMMgreRUvJzD/n37kHhw11VWXOWTd1j 9NRYiiGJacdxL8PyZvbmtMQ= Received: (qmail 74586 invoked by alias); 27 Nov 2015 13:00:43 -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 74568 invoked by uid 89); 27 Nov 2015 13:00:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f51.google.com Received: from mail-qg0-f51.google.com (HELO mail-qg0-f51.google.com) (209.85.192.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 27 Nov 2015 13:00:39 +0000 Received: by qgcc31 with SMTP id c31so71916346qgc.3 for ; Fri, 27 Nov 2015 05:00:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=G7JR2ZhSwPy2jS8vLPVtWaqvtgfrEa9ETfL+3NhexIQ=; b=HuKZ68ztBz4GDfhQiag0cMMqg1EQic/DpcdMC0xkcxmVr8eE0R0b18OKUu8urpLuR7 u3NU3pcWadZrzHuGKKMjp/llbMDJHH5pkaFcNqf25bzLvI4ktf1wayOmwzA4epdOT7Ah C7/5wQ7jePJlRM3EvCvdRE+Ld4KuR1x5sKmkIu9F/iHcKE4rvFIQoOHKm/q8KTVS/l2U 3G0nwKiPDjAkHT9b/5JCalRdqRwIwOLbbJtQBTKY1K0qVmPacQfwlEpJCDIzmt0IgFbM YFibb0K91vU/HtrfMhYHldc8UaI8520+rCjoepKERdDOZYjCSOtMMClSZyJiJIXXbY9F 1akg== X-Gm-Message-State: ALoCoQmRxQCjjp8RCHB66+ACWpD+3L0uckes573jQNZoxVW6J6VmB0eAp0TNKqW845RZk7GXw8gE MIME-Version: 1.0 X-Received: by 10.140.153.213 with SMTP id 204mr57886133qhz.30.1448629236632; Fri, 27 Nov 2015 05:00:36 -0800 (PST) Received: by 10.140.82.137 with HTTP; Fri, 27 Nov 2015 05:00:36 -0800 (PST) Date: Fri, 27 Nov 2015 14:00:36 +0100 Message-ID: Subject: [testsuite][ARM target attributes] Fix effective_target tests From: Christophe Lyon To: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes Hi, After the recent commits from Christian adding target attributes support for ARM FPU settings, I've noticed that some of the tests were failing because of incorrect assumptions wrt to the default cpu/fpu/float-abi of the compiler. This patch fixes the problems I've noticed in the following way: - do not force -mfloat-abi=softfp in dg-options, to avoid conflicts when gcc is configured --with-float=hard - change arm_vfp_ok such that it tries several -mfpu/-mfloat-abi flags, checks that __ARM_FP is defined and __ARM_NEON_FP is not defined - introduce arm_fp_ok, which is similar but does not enforce fpu setting - add a new effective_target: arm_crypto_pragma_ok to check that setting this fpu via a pragma is actually supported by the current "multilib". This is different from checking the command-line option because the pragma might conflict with the command-line options in use. The updates in the testcases are as follows: - attr-crypto.c, we have to make sure that the defaut fpu does not conflict with the one forced by pragma. That's why I use the arm_vfp options/effective_target. This is needed if gcc has been configured --with-fpu=neon-fp16, as the pragma fpu=crypto-neon-fp-armv8 would conflict. - attr-neon-builtin-fail.c: use arm_fp to force the appropriate float-abi setting. Enforcing fpu is not needed here. - attr-neon-fp16.c: similar, I also removed arm_neon_ok since it was not necessary to make the test pass in my testing. On second thought, I'm wondering whether I should leave it and make the test unsupported in more cases (such as when forcing -march=armv5t, although it does pass with this patch) - attr-neon2.c: use arm_vfp to force the appropriate float-abi setting. Enforcing mfpu=vfp is needed to avoid conflict with the pragma target fpu=neon (for instance if the toolchain default is neon-fp16) - attr-neon3.c: similar Tested on a variety of configurations, see: http://people.linaro.org/~christophe.lyon/cross-validation/gcc-test-patches/230929-target-attr/report-build-info.html Note that the regressions reported fall into 3 categories: - when forcing march=armv5t: tests are now unsupported because I modified arm_crypto_ok to require arm_v8_neon_ok instead of arm32. - the warning reported by attr-neon-builtin-fail.c moved from line 12 to 14 and is thus seen as a regression + one improvement - finally, attr-neon-fp16.c causes an ICE on armeb compilers, for which I need to post a bugzilla. TBH, I'm a bit concerned by the complexity of all these multilib-like conditions. I'm confident that I'm still missing some combinations :-) And with new target attributes coming, new architectures etc... all this logic is likely to become even more complex. That being said, OK for trunk? Christophe 2015-11-27 Christophe Lyon * lib/target-supports.exp (check_effective_target_arm_vfp_ok_nocache): New. (check_effective_target_arm_vfp_ok): Call the new check_effective_target_arm_vfp_ok_nocache function. (check_effective_target_arm_fp_ok_nocache): New. (check_effective_target_arm_fp_ok): New. (add_options_for_arm_fp): New. (check_effective_target_arm_crypto_ok_nocache): Require target_arm_v8_neon_ok instead of arm32. (check_effective_target_arm_crypto_pragma_ok_nocache): New. (check_effective_target_arm_crypto_pragma_ok): New. (add_options_for_arm_vfp): New. * gcc.target/arm/attr-crypto.c: Use arm_crypto_pragma_ok effective target. Do not force -mfloat-abi=softfp, use arm_vfp effective target instead. * gcc.target/arm/attr-neon-builtin-fail.c: Do not force -mfloat-abi=softfp, use arm_fp effective target instead. * gcc.target/arm/attr-neon-fp16.c: Likewise. Remove arm_neon_ok dependency. * gcc.target/arm/attr-neon2.c: Do not force -mfloat-abi=softfp, use arm_vfp effective target instead. * gcc.target/arm/attr-neon3.c: Likewise. diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 254c4e3..886ad66 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -2664,17 +2664,34 @@ proc check_effective_target_arm_vect_no_misalign { } { # Return 1 if this is an ARM target supporting -mfpu=vfp -# -mfloat-abi=softfp. Some multilibs may be incompatible with these -# options. +# -mfloat-abi=softfp or equivalent options. Some multilibs may be +# incompatible with these options. Also set et_arm_vfp_flags to the +# best options to add. -proc check_effective_target_arm_vfp_ok { } { +proc check_effective_target_arm_vfp_ok_nocache { } { + global et_arm_vfp_flags + set et_arm_vfp_flags "" if { [check_effective_target_arm32] } { - return [check_no_compiler_messages arm_vfp_ok object { - int dummy; - } "-mfpu=vfp -mfloat-abi=softfp"] - } else { - return 0 + foreach flags {"-mfpu=vfp" "-mfpu=vfp -mfloat-abi=softfp" "-mfpu=vfp -mfloat-abi=hard"} { + if { [check_no_compiler_messages_nocache arm_vfp_ok object { + #ifndef __ARM_FP + #error __ARM_FP not defined + #endif + #ifdef __ARM_NEON_FP + #error __ARM_NEON_FP defined + #endif + } "$flags" ] } { + set et_arm_vfp_flags $flags + return 1 + } + } } + return 0 +} + +proc check_effective_target_arm_vfp_ok { } { + return [check_cached_effective_target arm_vfp_ok \ + check_effective_target_arm_vfp_ok_nocache] } # Return 1 if this is an ARM target supporting -mfpu=vfp3 @@ -2721,6 +2738,47 @@ proc check_effective_target_arm_hard_vfp_ok { } { } } +# Return 1 if this is an ARM target defining __ARM_FP. We may need +# -mfloat-abi=softfp or equivalent options. Some multilibs may be +# incompatible with these options. Also set et_arm_fp_flags to the +# best options to add. + +proc check_effective_target_arm_fp_ok_nocache { } { + global et_arm_fp_flags + set et_arm_fp_flags "" + if { [check_effective_target_arm32] } { + foreach flags {"" "-mfloat-abi=softfp" "-mfloat-abi=hard"} { + if { [check_no_compiler_messages_nocache arm_fp_ok object { + #ifndef __ARM_FP + #error __ARM_FP not defined + #endif + } "$flags"] } { + set et_arm_fp_flags $flags + return 1 + } + } + } + + return 0 +} + +proc check_effective_target_arm_fp_ok { } { + return [check_cached_effective_target arm_fp_ok \ + check_effective_target_arm_fp_ok_nocache] +} + +# Add the options needed to define __ARM_FP. We need either +# -mfloat-abi=softfp or -mfloat-abi=hard, but if one is already +# specified by the multilib, use it. + +proc add_options_for_arm_fp { flags } { + if { ! [check_effective_target_arm_fp_ok] } { + return "$flags" + } + global et_arm_fp_flags + return "$flags $et_arm_fp_flags" +} + # Return 1 if this is an ARM target that supports DSP multiply with # current multilib flags. @@ -2753,7 +2811,7 @@ proc check_effective_target_arm_unaligned { } { proc check_effective_target_arm_crypto_ok_nocache { } { global et_arm_crypto_flags set et_arm_crypto_flags "" - if { [check_effective_target_arm32] } { + if { [check_effective_target_arm_v8_neon_ok] } { foreach flags {"" "-mfloat-abi=softfp" "-mfpu=crypto-neon-fp-armv8" "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"} { if { [check_no_compiler_messages_nocache arm_crypto_ok object { #include "arm_neon.h" @@ -2779,6 +2837,54 @@ proc check_effective_target_arm_crypto_ok { } { check_effective_target_arm_crypto_ok_nocache] } +# Return 1 if this is an ARM target supporting pragma target +# -mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp or equivalent options. +# Some multilibs may be incompatible with these options. Also set +# et_arm_crypto_pragma_flags to the best options to add. + +proc check_effective_target_arm_crypto_pragma_ok_nocache { } { + global et_arm_crypto_pragma_flags + set et_arm_crypto_pragma_flags "" + if { [check_effective_target_arm_v8_neon_ok] } { + foreach flags {"" "-mfloat-abi=softfp" "-mfpu=crypto-neon-fp-armv8" "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"} { + if { [check_no_compiler_messages_nocache arm_crypto_pragmaok object { + #pragma GCC target ("fpu=crypto-neon-fp-armv8") + #include "arm_neon.h" + uint8x16_t + foo (uint8x16_t a, uint8x16_t b) + { + return vaeseq_u8 (a, b); + } + } "[add_options_for_arm_v8_neon ""] $flags"] } { + set et_arm_crypto_pragma_flags "[add_options_for_arm_v8_neon ""] $flags" + return 1 + } + } + } + + return 0 +} + +# Return 1 if this is an ARM target supporting pragma target +# -mfpu=crypto-neon-fp-armv8. + +proc check_effective_target_arm_crypto_pragma_ok { } { + return [check_cached_effective_target arm_crypto_pragma_ok \ + check_effective_target_arm_crypto_pragma_ok_nocache] +} + +# Add the options needed for VFP. We need either -mfloat-abi=softfp +# or -mfloat-abi=hard, but if one is already specified by the +# multilib, use it. + +proc add_options_for_arm_vfp { flags } { + if { ! [check_effective_target_arm_vfp_ok] } { + return "$flags" + } + global et_arm_vfp_flags + return "$flags $et_arm_vfp_flags" +} + # Add options for crypto extensions. proc add_options_for_arm_crypto { flags } { if { ! [check_effective_target_arm_crypto_ok] } { @@ -2897,8 +3003,8 @@ proc check_effective_target_arm_crc_ok { } { # Return 1 if this is an ARM target supporting -mfpu=neon-fp16 # -mfloat-abi=softfp or equivalent options. Some multilibs may be -# incompatible with these options. Also set et_arm_neon_flags to the -# best options to add. +# incompatible with these options. Also set et_arm_neon_fp16_flags to +# the best options to add. proc check_effective_target_arm_neon_fp16_ok_nocache { } { global et_arm_neon_fp16_flags diff --git a/gcc/testsuite/gcc.target/arm/attr-crypto.c b/gcc/testsuite/gcc.target/arm/attr-crypto.c index 1db5984..b703fbc 100644 --- a/gcc/testsuite/gcc.target/arm/attr-crypto.c +++ b/gcc/testsuite/gcc.target/arm/attr-crypto.c @@ -1,6 +1,10 @@ /* { dg-do compile } */ -/* { dg-require-effective-target arm_crypto_ok } */ -/* { dg-options "-O2 -mfloat-abi=softfp" } */ +/* Make sure we can force fpu=vfp before switching using the + pragma. */ +/* { dg-require-effective-target arm_vfp_ok } */ +/* { dg-require-effective-target arm_crypto_pragma_ok } */ +/* { dg-options "-O2 -march=armv8-a" } */ +/* { dg-add-options arm_vfp } */ #pragma GCC target ("fpu=crypto-neon-fp-armv8") diff --git a/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail.c b/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail.c index 6ac32fc..05dc579 100644 --- a/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail.c +++ b/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail.c @@ -1,7 +1,9 @@ /* Check that calling a neon builtin from a function compiled with vfp fails. */ /* { dg-do compile } */ +/* { dg-require-effective-target arm_fp_ok } */ /* { dg-require-effective-target arm_neon_ok } */ -/* { dg-options "-O2 -mfloat-abi=softfp" } */ +/* { dg-options "-O2" } */ +/* { dg-add-options arm_fp } */ #include @@ -12,6 +14,5 @@ foo (uint8x16_t *p) *p = vmovq_n_u8 (3); /* { dg-message "called from here" } */ } -/* { dg-error "inlining failed in call to always_inline" "" { target *-*-* } 0 } - */ +/* { dg-error "inlining failed in call to always_inline" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/arm/attr-neon-fp16.c b/gcc/testsuite/gcc.target/arm/attr-neon-fp16.c index 3cf8918..984992f 100644 --- a/gcc/testsuite/gcc.target/arm/attr-neon-fp16.c +++ b/gcc/testsuite/gcc.target/arm/attr-neon-fp16.c @@ -1,6 +1,7 @@ /* { dg-do compile } */ -/* { dg-require-effective-target arm_neon_ok } */ -/* { dg-options "-mfp16-format=ieee -mfloat-abi=softfp" } */ +/* { dg-require-effective-target arm_fp_ok } */ +/* { dg-options "-mfp16-format=ieee" } */ +/* { dg-add-options arm_fp } */ #include "arm_neon.h" diff --git a/gcc/testsuite/gcc.target/arm/attr-neon2.c b/gcc/testsuite/gcc.target/arm/attr-neon2.c index 819fad4..79133e5 100644 --- a/gcc/testsuite/gcc.target/arm/attr-neon2.c +++ b/gcc/testsuite/gcc.target/arm/attr-neon2.c @@ -1,6 +1,8 @@ /* { dg-do compile } */ /* { dg-require-effective-target arm_neon_ok } */ -/* { dg-options "-O2 -mfloat-abi=softfp -mfpu=vfp" } */ +/* { dg-require-effective-target arm_vfp_ok } */ +/* { dg-options "-O2" } */ +/* { dg-add-options arm_vfp } */ #pragma GCC target ("fpu=neon") #include diff --git a/gcc/testsuite/gcc.target/arm/attr-neon3.c b/gcc/testsuite/gcc.target/arm/attr-neon3.c index 30a1479..0d31fb5 100644 --- a/gcc/testsuite/gcc.target/arm/attr-neon3.c +++ b/gcc/testsuite/gcc.target/arm/attr-neon3.c @@ -1,6 +1,8 @@ /* { dg-do compile } */ /* { dg-require-effective-target arm_crypto_ok } */ -/* { dg-options "-O2 -mfloat-abi=softfp -mfpu=vfp" } */ +/* { dg-require-effective-target arm_vfp_ok } */ +/* { dg-options "-O2" } */ +/* { dg-add-options arm_vfp } */ #include