This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix libgfortran bootstrap error on x86_64-mingw32 (PR target/79127)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org, JonY <10walls at gmail dot com>, Kai Tietz <ktietz70 at googlemail dot com>, Uros Bizjak <ubizjak at gmail dot com>
- Cc: Rainer Emrich <rainer at emrich-ebersheim dot de>
- Date: Thu, 19 Jan 2017 12:18:34 +0100
- Subject: [PATCH] Fix libgfortran bootstrap error on x86_64-mingw32 (PR target/79127)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Apparently the Windows SEH has problems with the [xyz]mm16 and later
registers that were added with AVX512F (usable in 64-bit code only),
if any of the zmm16 to zmm31 registers are used in some function compiled
with avx512f or later, GCC emits .seh_savexmm %xmm16, ... directive or
similar and even binutils 2.27 doesn't handle that.
I don't know where the bug is (if the SEH format even allows registers
%xmm16 to %xmm31, what ABI is mingw meant to use for these registers
(if they are meant to be call saved (like %xmm6 to %xmm15) or call used),
and whether the bug is on the GCC side, or binutils side, or just that
AVX512* can't be really used safely on mingw (perhaps a quick hack could
be to make those registers fixed on mingw).
This patch doesn't address anything from it, just attempts to fix the
bootstrap problem by not using avx512f optimized code on mingw until that
issue is resolved.
The #ifdef __x86_64__ in there is because zmm16+ registers can only be used
with -m64 or -mx32, not with -m32 (similarly to xmm8 to xmm15).
Bootstrapped/regtested on x86_64-linux and i686-linux (where HAVE_AVX5412F
is still defined as before assuming not very old binutils) and by Rainer
as mentioned in the PR on x86_64-w64-mingw32, ok for trunk?
2017-01-19 Jakub Jelinek <jakub@redhat.com>
PR target/79127
* acinclude.m4 (LIBGFOR_CHECK_AVX512F): Ensure the test clobbers
some zmm16+ registers to verify they are handled by unwind info
properly if needed.
* configure: Regenerated.
--- libgfortran/acinclude.m4.jj 2016-12-05 10:28:28.000000000 +0100
+++ libgfortran/acinclude.m4 2017-01-18 16:36:23.360736182 +0100
@@ -437,7 +437,11 @@ AC_DEFUN([LIBGFOR_CHECK_AVX512F], [
typedef double __m512d __attribute__ ((__vector_size__ (64)));
__m512d _mm512_add (__m512d a)
{
- return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
+ __m512d b = __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
+#ifdef __x86_64__
+ asm volatile ("" : : : "zmm16", "zmm17", "zmm18", "zmm19");
+#endif
+ return b;
}]], [[]])],
AC_DEFINE(HAVE_AVX512F, 1,
[Define if AVX512f instructions can be compiled.]),
--- libgfortran/configure.jj 2017-01-17 10:28:41.000000000 +0100
+++ libgfortran/configure 2017-01-18 16:36:28.592668260 +0100
@@ -26300,7 +26300,11 @@ rm -f core conftest.err conftest.$ac_obj
typedef double __m512d __attribute__ ((__vector_size__ (64)));
__m512d _mm512_add (__m512d a)
{
- return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
+ __m512d b = __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
+#ifdef __x86_64__
+ asm volatile ("" : : : "zmm16", "zmm17", "zmm18", "zmm19");
+#endif
+ return b;
}
int
main ()
Jakub