This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: avx runtime check
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Mike Stump <mikestump at comcast dot net>
- Cc: Uros Bizjak <ubizjak at gmail dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 19 May 2014 10:47:42 +0200
- Subject: Re: avx runtime check
- Authentication-results: sourceware.org; auth=none
- References: <42629FC8-9372-410B-B9C0-7C6341B3D812 at comcast dot net> <a5376cf6-3f36-4b83-ae69-bf9f4fd52d9c at email dot android dot com> <CF012473-07CE-4442-99CB-C4DE5DD573C3 at comcast dot net>
On Fri, May 16, 2014 at 4:20 PM, Mike Stump <mikestump@comcast.net> wrote:
> On May 15, 2014, at 11:52 PM, Richard Biener <richard.guenther@gmail.com> wrote:
>> On May 16, 2014 4:47:11 AM CEST, Mike Stump <mikestump@comcast.net> wrote:
>>> This reorders the avx checks and gates on a target triplet check before
>>> compiling any code.
>>
>> Can you explain why?
>
> Sure, because check_avx_hw_available runs [istarget x86_64-*-*] || [istarget i?86-*-*] before doing anything, like compiling:
>
> typedef double __m512d __attribute__ ((__vector_size__ (64)));
>
> __m512d _mm512_add (__m512d a)
> {
> return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
> }
>
> with -mavx512f, which my target doesnât have, but even running a compilation of that seems wrong. The other possibility would be to add in a:
>
> # If this is not the right target then we can skip the test.
> if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
> expr 0
> } else {
>
> into the test for check_effective_target_avx512f.
Yes, that looks like a better fix.
Ok with that change.
Thanks,
Richard.
>
> proc check_effective_target_avx512f { } {
> return [check_no_compiler_messages avx512f object {
> typedef double __m512d __attribute__ ((__vector_size__ (64)));
>
> __m512d _mm512_add (__m512d a)
> {
> return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
> }
> } "-O2 -mavx512f" ]
> }
>
> proc check_avx_hw_available { } {
> return [check_cached_effective_target avx_hw_available {
> # If this is not the right target then we can skip the test.
> if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
> expr 0
> } else {
> check_runtime_nocache avx_hw_available {
> #include "cpuid.h"
> int main ()
> {
> unsigned int eax, ebx, ecx, edx;
> if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
> return ((ecx & (bit_AVX | bit_OSXSAVE))
> != (bit_AVX | bit_OSXSAVE));
> return 1;
> }
> } ""
> }
> }]
> }
>
>
>>> diff --git a/gcc/testsuite/lib/target-supports.exp
>>> b/gcc/testsuite/lib/target-supports.exp
>>> index 40b5414..103a28a 100644
>>> --- a/gcc/testsuite/lib/target-supports.exp
>>> +++ b/gcc/testsuite/lib/target-supports.exp
>>> @@ -1353,8 +1353,8 @@ proc check_effective_target_sse2_runtime { } {
>>> # Return 1 if the target supports running AVX executables, 0 otherwise.
>>>
>>> proc check_effective_target_avx_runtime { } {
>>> - if { [check_effective_target_avx]
>>> - && [check_avx_hw_available]
>>> + if { [check_avx_hw_available]
>>> + && [check_effective_target_avx]
>>> && [check_avx_os_support_available] } {
>>> return 1
>>> }