public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] i386: Make xmm16-xmm31 call used even in ms ABI [PR65782]
@ 2020-09-17 16:42 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 16:42 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6bb71826eed7a93033280159a9e9e64b5a1724fd
commit 6bb71826eed7a93033280159a9e9e64b5a1724fd
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Feb 14 15:47:55 2020 +0100
i386: Make xmm16-xmm31 call used even in ms ABI [PR65782]
On Tue, Feb 04, 2020 at 11:16:06AM +0100, Uros Bizjak wrote:
> I guess that Comment #9 patch form the PR should be trivially correct,
> but althouhg it looks obvious, I don't want to propose the patch since
> I have no means of testing it.
I don't have means of testing it either.
https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=vs-2019
is quite explicit that [xyz]mm16-31 are call clobbered and only xmm6-15 (low
128-bits only) are call preserved.
We are talking e.g. about
/* { dg-options "-O2 -mabi=ms -mavx512vl" } */
typedef double V __attribute__((vector_size (16)));
void foo (void);
V bar (void);
void baz (V);
void
qux (void)
{
V c;
{
register V a __asm ("xmm18");
V b = bar ();
asm ("" : "=x" (a) : "0" (b));
c = a;
}
foo ();
{
register V d __asm ("xmm18");
V e;
d = c;
asm ("" : "=x" (e) : "0" (d));
baz (e);
}
}
where according to the MSDN doc gcc incorrectly holds the c value
in xmm18 register across the foo call; if foo is compiled by some Microsoft
compiler (or LLVM), then it could clobber %xmm18.
If all xmm18 occurrences are changed to say xmm15, then it is valid to hold
the 128-bit value across the foo call (though, surprisingly, LLVM saves it
into stack anyway).
The other parts are I guess mainly about SEH. Consider e.g.
void
foo (void)
{
register double x __asm ("xmm14");
register double y __asm ("xmm18");
asm ("" : "=x" (x));
asm ("" : "=v" (y));
x += y;
y += x;
asm ("" : : "x" (x));
asm ("" : : "v" (y));
}
looking at cross-compiler output, with -O2 -mavx512f this emits
.file "abcdeq.c"
.text
.align 16
.globl foo
.def foo; .scl 2; .type 32; .endef
.seh_proc foo
foo:
subq $40, %rsp
.seh_stackalloc 40
vmovaps %xmm14, (%rsp)
.seh_savexmm %xmm14, 0
vmovaps %xmm18, 16(%rsp)
.seh_savexmm %xmm18, 16
.seh_endprologue
vaddsd %xmm18, %xmm14, %xmm14
vaddsd %xmm18, %xmm14, %xmm18
vmovaps (%rsp), %xmm14
vmovaps 16(%rsp), %xmm18
addq $40, %rsp
ret
.seh_endproc
.ident "GCC: (GNU) 10.0.1 20200207 (experimental)"
Does whatever assembler mingw64 uses even assemble this (I mean the
.seh_savexmm %xmm16, 16 could be problematic)?
I can find e.g.
https://stackoverflow.com/questions/43152633/invalid-register-for-seh-savexmm-in-cygwin/43210527
which then links to
https://gcc.gnu.org/PR65782
2020-02-08 Uroš Bizjak <ubizjak@gmail.com>
Jakub Jelinek <jakub@redhat.com>
PR target/65782
* config/i386/i386.h (CALL_USED_REGISTERS): Make
xmm16-xmm31 call-used even in 64-bit ms-abi.
* gcc.target/i386/pr65782.c: New test.
Co-authored-by: Uroš Bizjak <ubizjak@gmail.com>
Diff:
---
gcc/ChangeLog | 8 ++++++++
gcc/config/i386/i386.h | 4 ++--
gcc/testsuite/ChangeLog | 7 +++++++
gcc/testsuite/gcc.target/i386/pr65782.c | 16 ++++++++++++++++
4 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f2463cb77bf..d266de47a9e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,14 @@
2020-02-14 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2020-02-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR libgomp/93515
+ * omp-low.c (use_pointer_for_field): For nested constructs, also
+ look for map clauses on target construct.
+ (scan_omp_1_stmt) <case GIMPLE_OMP_TARGET>: Bump temporarily
+ taskreg_nesting_level.
+
2020-02-05 Jakub Jelinek <jakub@redhat.com>
PR middle-end/93555
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index d594d4a417c..aba63fb7a80 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -1062,9 +1062,9 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
/*xmm8,xmm9,xmm10,xmm11,xmm12,xmm13,xmm14,xmm15*/ \
6, 6, 6, 6, 6, 6, 6, 6, \
/*xmm16,xmm17,xmm18,xmm19,xmm20,xmm21,xmm22,xmm23*/ \
- 6, 6, 6, 6, 6, 6, 6, 6, \
+ 1, 1, 1, 1, 1, 1, 1, 1, \
/*xmm24,xmm25,xmm26,xmm27,xmm28,xmm29,xmm30,xmm31*/ \
- 6, 6, 6, 6, 6, 6, 6, 6, \
+ 1, 1, 1, 1, 1, 1, 1, 1, \
/* k0, k1, k2, k3, k4, k5, k6, k7*/ \
1, 1, 1, 1, 1, 1, 1, 1, \
/* b0, b1, b2, b3*/ \
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 756659dc249..0589952834e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,13 @@
2020-02-14 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2020-02-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/93555
+ * c-c++-common/gomp/pr93555-1.c: New test.
+ * c-c++-common/gomp/pr93555-2.c: New test.
+ * gfortran.dg/gomp/pr93555.f90: New test.
+
2020-01-30 Jakub Jelinek <jakub@redhat.com>
PR middle-end/93505
diff --git a/gcc/testsuite/gcc.target/i386/pr65782.c b/gcc/testsuite/gcc.target/i386/pr65782.c
new file mode 100644
index 00000000000..298dca1be97
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr65782.c
@@ -0,0 +1,16 @@
+/* PR target/65782 */
+/* { dg-do assemble { target { avx512vl && { ! ia32 } } } } */
+/* { dg-options "-O2 -mavx512vl" } */
+
+void
+foo (void)
+{
+ register double x __asm ("xmm14");
+ register double y __asm ("xmm18");
+ asm ("" : "=x" (x));
+ asm ("" : "=v" (y));
+ x += y;
+ y += x;
+ asm ("" : : "x" (x));
+ asm ("" : : "v" (y));
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-17 16:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 16:42 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] i386: Make xmm16-xmm31 call used even in ms ABI [PR65782] Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).