[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 --- Comment #13 from Richard Biener --- (In reply to H.J. Lu from comment #12) > Created attachment 49495 [details] > Something like this. Doesn't look much better IMHO. A __builtin_cpu_supported_as_compiled () would be nice to have though (match up what is supported with the active -mISA flags).
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 --- Comment #12 from H.J. Lu --- Created attachment 49495 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49495&action=edit Something like this.
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 --- Comment #11 from rguenther at suse dot de --- On Tue, 3 Nov 2020, hjl.tools at gmail dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 > > --- Comment #10 from H.J. Lu --- > FWIW, x86 source in gcc testsuite should be converted to > __builtin_cpu_supports(). The check_vect () is quite convenient since it allows you to build-test with target support you cannot run on via --target_board=unix/-mavx512f for example (well, it is incomplete and support for avx512 testing hasn't been added). I don't see how the same functionality can be achieved with a series of __builtin_cpu_supports checks (unless we only adjust tree-vect.h to do # if defined(__AVX2__) if (!__builtin_cpu_supports ("magic")) exit (0); # ...
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 --- Comment #10 from H.J. Lu --- FWIW, x86 source in gcc testsuite should be converted to __builtin_cpu_supports().
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 Richard Biener changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #9 from Richard Biener --- Fixed everywhere.
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 --- Comment #8 from CVS Commits --- The releases/gcc-8 branch has been updated by Richard Biener : https://gcc.gnu.org/g:80b6f6cf6374a6541a7515d7bfef1a3506db2a3d commit r8-10606-g80b6f6cf6374a6541a7515d7bfef1a3506db2a3d Author: Richard Biener Date: Tue Nov 3 10:24:02 2020 +0100 testsuite/97688 - fix check_vect () with __AVX2__ This fixes the cpuid check to always specify a subleaf zero which is required to detect AVX2 and doesn't hurt for level one. Without this fix we get zero runtime coverage when -mavx2 is specified. 2020-11-03 Richard Biener PR testsuite/97688 * gcc.dg/vect/tree-vect.h (check_vect): Fix the x86 cpuid check to always specify subleaf zero. (cherry picked from commit 8414529156e0bca37647c440c71beeca1d04ac86)
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 --- Comment #7 from CVS Commits --- The releases/gcc-9 branch has been updated by Richard Biener : https://gcc.gnu.org/g:e42cb1d48035b85a43adb202433ff0193c151410 commit r9-9021-ge42cb1d48035b85a43adb202433ff0193c151410 Author: Richard Biener Date: Tue Nov 3 10:24:02 2020 +0100 testsuite/97688 - fix check_vect () with __AVX2__ This fixes the cpuid check to always specify a subleaf zero which is required to detect AVX2 and doesn't hurt for level one. Without this fix we get zero runtime coverage when -mavx2 is specified. 2020-11-03 Richard Biener PR testsuite/97688 * gcc.dg/vect/tree-vect.h (check_vect): Fix the x86 cpuid check to always specify subleaf zero. (cherry picked from commit 8414529156e0bca37647c440c71beeca1d04ac86)
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 --- Comment #6 from CVS Commits --- The releases/gcc-10 branch has been updated by Richard Biener : https://gcc.gnu.org/g:725244355f83de56f8692abc6c0e1b3d4d248198 commit r10-8968-g725244355f83de56f8692abc6c0e1b3d4d248198 Author: Richard Biener Date: Tue Nov 3 10:24:02 2020 +0100 testsuite/97688 - fix check_vect () with __AVX2__ This fixes the cpuid check to always specify a subleaf zero which is required to detect AVX2 and doesn't hurt for level one. Without this fix we get zero runtime coverage when -mavx2 is specified. 2020-11-03 Richard Biener PR testsuite/97688 * gcc.dg/vect/tree-vect.h (check_vect): Fix the x86 cpuid check to always specify subleaf zero. (cherry picked from commit 8414529156e0bca37647c440c71beeca1d04ac86)
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 --- Comment #5 from CVS Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:8414529156e0bca37647c440c71beeca1d04ac86 commit r11-4647-g8414529156e0bca37647c440c71beeca1d04ac86 Author: Richard Biener Date: Tue Nov 3 10:24:02 2020 +0100 testsuite/97688 - fix check_vect () with __AVX2__ This fixes the cpuid check to always specify a subleaf zero which is required to detect AVX2 and doesn't hurt for level one. Without this fix we get zero runtime coverage when -mavx2 is specified. 2020-11-03 Richard Biener PR testsuite/97688 * gcc.dg/vect/tree-vect.h (check_vect): Fix the x86 cpuid check to always specify subleaf zero.
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 --- Comment #4 from Uroš Bizjak --- (In reply to Richard Biener from comment #3) > Ah. So I guess > > diff --git a/gcc/testsuite/gcc.dg/vect/tree-vect.h > b/gcc/testsuite/gcc.dg/vect/tree-vect.h > index 5d8d9eba3f8..c4b81441216 100644 > --- a/gcc/testsuite/gcc.dg/vect/tree-vect.h > +++ b/gcc/testsuite/gcc.dg/vect/tree-vect.h > @@ -52,7 +52,7 @@ check_vect (void) > want_level = 1, want_d = bit_SSE2; > # endif > > -if (!__get_cpuid (want_level, &a, &b, &c, &d) > +if (!__get_cpuid_count (want_level, 0, &a, &b, &c, &d) > || ((b & want_b) | (c & want_c) | (d & want_d)) == 0) >exit (0); >} > > will work. Exactly. The patch is pre-approved.
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 Richard Biener changed: What|Removed |Added Ever confirmed|0 |1 Status|UNCONFIRMED |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Last reconfirmed||2020-11-03 --- Comment #3 from Richard Biener --- Ah. So I guess diff --git a/gcc/testsuite/gcc.dg/vect/tree-vect.h b/gcc/testsuite/gcc.dg/vect/tree-vect.h index 5d8d9eba3f8..c4b81441216 100644 --- a/gcc/testsuite/gcc.dg/vect/tree-vect.h +++ b/gcc/testsuite/gcc.dg/vect/tree-vect.h @@ -52,7 +52,7 @@ check_vect (void) want_level = 1, want_d = bit_SSE2; # endif -if (!__get_cpuid (want_level, &a, &b, &c, &d) +if (!__get_cpuid_count (want_level, 0, &a, &b, &c, &d) || ((b & want_b) | (c & want_c) | (d & want_d)) == 0) exit (0); } will work.
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 --- Comment #2 from Richard Biener --- Hmm, it doesn't work on a i7-8565U either ... Doesn't work means check_vect () does exit (0). Those do not end up UNSUPPORTED (not sure if using a magic exit code to communicate this would be possible). Looks like $rcx is not cleared before 'cpuid' and we get garbage?! If I set $rcx to zero it works. The comment in cpuid.h says /* At least one cpu (Winchip 2) does not set %ebx and %ecx for cpuid leaf 1. Forcibly zero the two registers before calling cpuid as a precaution. */ but it does the clearing only for constant level (doesn't work at -O0 which is where I debugged check_vect). At -O2 I see Dump of assembler code for function check_vect: 0x00400680 <+0>: push %rbx 0x00400681 <+1>: mov$0x4006c0,%esi 0x00400686 <+6>: mov$0x4,%edi 0x0040068b <+11>:callq 0x400490 => 0x00400690 <+16>:xor%eax,%eax 0x00400692 <+18>:cpuid 0x00400694 <+20>:cmp$0x6,%eax 0x00400697 <+23>:jbe0x4006a5 0x00400699 <+25>:mov$0x7,%eax 0x0040069e <+30>:cpuid 0x004006a0 <+32>:and$0x20,%ebx 0x004006a3 <+35>:jne0x4006ac 0x004006a5 <+37>:xor%edi,%edi 0x004006a7 <+39>:callq 0x4004a0 0x004006ac <+44>:xor%esi,%esi 0x004006ae <+46>:mov$0x4,%edi 0x004006b3 <+51>:pop%rbx 0x004006b4 <+52>:jmpq 0x400490 so no zeroing of the regs of the result of the __maxlevel call and we call cpuid with rax0x7 7 rbx0x68747541 1752462657 rcx0x444d4163 1145913699 rdx0x69746e65 1769238117 rsi0x7fffd8b0 140737488345264 rdi0x0 0 and on zen2 get rax0x0 0 rbx0x0 0 rcx0x0 0 rdx0x0 0 on i7-8565U the garbage is similar: rax 0x7 rbx 0x756e6547 rcx 0x6c65746e rdx 0x49656e69 with same all-zero result.
[Bug testsuite/97688] check_vect doesn't detect AVX2 on zen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97688 --- Comment #1 from Uroš Bizjak --- AVX2 should be detected using __get_cpuid_count, because a sub-leaf needs to be specified for leaf 7.