public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
@ 2017-09-14  3:57 Daniel Santos
  2017-09-17 15:53 ` Uros Bizjak
  0 siblings, 1 reply; 20+ messages in thread
From: Daniel Santos @ 2017-09-14  3:57 UTC (permalink / raw)
  To: gcc-patches, Uros Bizjak, Jan Hubicka, Ian Lance Taylor,
	Rainer Orth, Mike Stump

I made a silly mistake in libgcc by testing the cpp macro __AVX__ to
determine rather to use movaps or vmovaps in the stubs.  This resulted
in the stubs choice of instruction being decided by the machine flags
when the compiler was built rather than those being supplied at the
command line.  This patch splits stubs into separate sse and avx
versions so that both are available.

gcc:
	config/i386/i386.c: (xlogue_layout::STUB_NAME_MAX_LEN): Increase to 20
	bytes.
	(xlogue_layout::s_stub_names): Add an additional size-2 diminsion.
	(xlogue_layout::get_stub_name): Modify to select the appropairate sse
	and avx version of the stub.

gcc/testsuite:
	gcc.target/i386/pr82196-1.c: New test.
	gcc.target/i386/pr82196-2.c: Likewise.

libgcc:
	config/i386/i386-asm.h (PASTE2): New macro.
	(ASMNAME): Modify to use PASTE2.
	(MS2SYSV_STUB_PREFIX): New macro for isa prefix.
	(MS2SYSV_STUB_BEGIN, MS2SYSV_STUB_END): New macros for stub headers.
	config/i386/resms64.S: Rename to a header file, use MS2SYSV_STUB_BEGIN
	instead of HIDDEN_FUNC and MS2SYSV_STUB_END instead of FUNC_END.
	config/i386/resms64f.S: Likewise.
	config/i386/resms64fx.S: Likewise.
	config/i386/resms64x.S: Likewise.
	config/i386/savms64.S: Likewise.
	config/i386/savms64f.S: Likewise.
	config/i386/avx_resms64.S: New file that only defines a macro and
	includes it's corresponding header file.
	config/i386/avx_resms64f.S: Likewise.
	config/i386/avx_resms64fx.S: Likewise.
	config/i386/avx_resms64x.S: Likewise.
	config/i386/avx_savms64.S: Likewise.
	config/i386/avx_savms64f.S: Likewise.
	config/i386/sse_resms64.S: Likewise.
	config/i386/sse_resms64f.S: Likewise.
	config/i386/sse_resms64fx.S: Likewise.
	config/i386/sse_resms64x.S: Likewise.
	config/i386/sse_savms64.S: Likewise.
	config/i386/sse_savms64f.S: Likewise.
	config/i386/t-msabi: Modified to add avx and sse versions of stubs.
Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
---
 gcc/config/i386/i386.c                          | 15 ++++++-----
 gcc/testsuite/gcc.target/i386/pr82196-1.c       | 14 ++++++++++
 gcc/testsuite/gcc.target/i386/pr82196-2.c       | 14 ++++++++++
 libgcc/config/i386/avx_resms64.S                |  2 ++
 libgcc/config/i386/avx_resms64f.S               |  2 ++
 libgcc/config/i386/avx_resms64fx.S              |  2 ++
 libgcc/config/i386/avx_resms64x.S               |  2 ++
 libgcc/config/i386/avx_savms64.S                |  2 ++
 libgcc/config/i386/avx_savms64f.S               |  2 ++
 libgcc/config/i386/i386-asm.h                   | 34 ++++++++++++++++---------
 libgcc/config/i386/{resms64.S => resms64.h}     | 28 ++++++++++----------
 libgcc/config/i386/{resms64f.S => resms64f.h}   | 24 ++++++++---------
 libgcc/config/i386/{resms64fx.S => resms64fx.h} | 24 ++++++++---------
 libgcc/config/i386/{resms64x.S => resms64x.h}   | 28 ++++++++++----------
 libgcc/config/i386/{savms64.S => savms64.h}     | 28 ++++++++++----------
 libgcc/config/i386/{savms64f.S => savms64f.h}   | 24 ++++++++---------
 libgcc/config/i386/sse_resms64.S                |  2 ++
 libgcc/config/i386/sse_resms64f.S               |  2 ++
 libgcc/config/i386/sse_resms64fx.S              |  2 ++
 libgcc/config/i386/sse_resms64x.S               |  2 ++
 libgcc/config/i386/sse_savms64.S                |  2 ++
 libgcc/config/i386/sse_savms64f.S               |  2 ++
 libgcc/config/i386/t-msabi                      | 18 ++++++++-----
 23 files changed, 173 insertions(+), 102 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr82196-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr82196-2.c
 create mode 100644 libgcc/config/i386/avx_resms64.S
 create mode 100644 libgcc/config/i386/avx_resms64f.S
 create mode 100644 libgcc/config/i386/avx_resms64fx.S
 create mode 100644 libgcc/config/i386/avx_resms64x.S
 create mode 100644 libgcc/config/i386/avx_savms64.S
 create mode 100644 libgcc/config/i386/avx_savms64f.S
 rename libgcc/config/i386/{resms64.S => resms64.h} (76%)
 rename libgcc/config/i386/{resms64f.S => resms64f.h} (79%)
 rename libgcc/config/i386/{resms64fx.S => resms64fx.h} (79%)
 rename libgcc/config/i386/{resms64x.S => resms64x.h} (77%)
 rename libgcc/config/i386/{savms64.S => savms64.h} (76%)
 rename libgcc/config/i386/{savms64f.S => savms64f.h} (79%)
 create mode 100644 libgcc/config/i386/sse_resms64.S
 create mode 100644 libgcc/config/i386/sse_resms64f.S
 create mode 100644 libgcc/config/i386/sse_resms64fx.S
 create mode 100644 libgcc/config/i386/sse_resms64x.S
 create mode 100644 libgcc/config/i386/sse_savms64.S
 create mode 100644 libgcc/config/i386/sse_savms64f.S

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index b2b02acc58a..f0d7d0eb196 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2513,7 +2513,7 @@ public:
   static const unsigned MAX_REGS = 18;
   static const unsigned MAX_EXTRA_REGS = MAX_REGS - MIN_REGS;
   static const unsigned VARIANT_COUNT = MAX_EXTRA_REGS + 1;
-  static const unsigned STUB_NAME_MAX_LEN = 16;
+  static const unsigned STUB_NAME_MAX_LEN = 20;
   static const char * const STUB_BASE_NAMES[XLOGUE_STUB_COUNT];
   static const unsigned REG_ORDER[MAX_REGS];
   static const unsigned REG_ORDER_REALIGN[MAX_REGS];
@@ -2536,7 +2536,7 @@ private:
   struct reginfo m_regs[MAX_REGS];
 
   /* Lazy-inited cache of symbol names for stubs.  */
-  static char s_stub_names[XLOGUE_STUB_COUNT][VARIANT_COUNT]
+  static char s_stub_names[2][XLOGUE_STUB_COUNT][VARIANT_COUNT]
 			  [STUB_NAME_MAX_LEN];
 
   static const xlogue_layout s_instances[XLOGUE_SET_COUNT];
@@ -2588,7 +2588,7 @@ const unsigned xlogue_layout::VARIANT_COUNT;
 const unsigned xlogue_layout::STUB_NAME_MAX_LEN;
 
 /* Initialize xlogue_layout::s_stub_names to zero.  */
-char xlogue_layout::s_stub_names[XLOGUE_STUB_COUNT][VARIANT_COUNT]
+char xlogue_layout::s_stub_names[2][XLOGUE_STUB_COUNT][VARIANT_COUNT]
 				[STUB_NAME_MAX_LEN];
 
 /* Instantiates all xlogue_layout instances.  */
@@ -2692,13 +2692,16 @@ const char *
 xlogue_layout::get_stub_name (enum xlogue_stub stub,
 			      unsigned n_extra_regs)
 {
-  char *name = s_stub_names[stub][n_extra_regs];
+  const int have_avx = TARGET_AVX;
+  char *name = s_stub_names[!!have_avx][stub][n_extra_regs];
 
   /* Lazy init */
   if (!*name)
     {
-      int res = snprintf (name, STUB_NAME_MAX_LEN, "__%s_%u",
-			  STUB_BASE_NAMES[stub], MIN_REGS + n_extra_regs);
+      int res = snprintf (name, STUB_NAME_MAX_LEN, "__%s_%s_%u",
+			  (have_avx ? "avx" : "sse"),
+			  STUB_BASE_NAMES[stub],
+			  MIN_REGS + n_extra_regs);
       gcc_checking_assert (res < (int)STUB_NAME_MAX_LEN);
     }
 
diff --git a/gcc/testsuite/gcc.target/i386/pr82196-1.c b/gcc/testsuite/gcc.target/i386/pr82196-1.c
new file mode 100644
index 00000000000..fa573dc6b66
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
+/* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
+/* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
+
+void __attribute__((sysv_abi)) a() {
+}
+
+static void __attribute__((sysv_abi)) (*volatile a_noinfo)() = a;
+
+void __attribute__((ms_abi)) b() {
+  __asm__ __volatile__ ("" :::"rbx", "rbp", "r12", "r13", "r14", "r15");
+  a_noinfo ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c b/gcc/testsuite/gcc.target/i386/pr82196-2.c
new file mode 100644
index 00000000000..31705bee29b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
+/* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
+/* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */
+
+void __attribute__((sysv_abi)) a() {
+}
+
+static void __attribute__((sysv_abi)) (*volatile a_noinfo)() = a;
+
+void __attribute__((ms_abi)) b() {
+  __asm__ __volatile__ ("" :::"rbx", "rbp", "r12", "r13", "r14", "r15");
+  a_noinfo ();
+}
diff --git a/libgcc/config/i386/avx_resms64.S b/libgcc/config/i386/avx_resms64.S
new file mode 100644
index 00000000000..2be744937cf
--- /dev/null
+++ b/libgcc/config/i386/avx_resms64.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_AVX
+#include "resms64.h"
diff --git a/libgcc/config/i386/avx_resms64f.S b/libgcc/config/i386/avx_resms64f.S
new file mode 100644
index 00000000000..76a1340ab1f
--- /dev/null
+++ b/libgcc/config/i386/avx_resms64f.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_AVX
+#include "resms64f.h"
diff --git a/libgcc/config/i386/avx_resms64fx.S b/libgcc/config/i386/avx_resms64fx.S
new file mode 100644
index 00000000000..2ea4738af7e
--- /dev/null
+++ b/libgcc/config/i386/avx_resms64fx.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_AVX
+#include "resms64fx.h"
diff --git a/libgcc/config/i386/avx_resms64x.S b/libgcc/config/i386/avx_resms64x.S
new file mode 100644
index 00000000000..14a53d4fcf9
--- /dev/null
+++ b/libgcc/config/i386/avx_resms64x.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_AVX
+#include "resms64x.h"
diff --git a/libgcc/config/i386/avx_savms64.S b/libgcc/config/i386/avx_savms64.S
new file mode 100644
index 00000000000..fed1620b968
--- /dev/null
+++ b/libgcc/config/i386/avx_savms64.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_AVX
+#include "savms64.h"
diff --git a/libgcc/config/i386/avx_savms64f.S b/libgcc/config/i386/avx_savms64f.S
new file mode 100644
index 00000000000..32279657e30
--- /dev/null
+++ b/libgcc/config/i386/avx_savms64f.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_AVX
+#include "savms64f.h"
diff --git a/libgcc/config/i386/i386-asm.h b/libgcc/config/i386/i386-asm.h
index 1387fd24b4f..424e0f72aac 100644
--- a/libgcc/config/i386/i386-asm.h
+++ b/libgcc/config/i386/i386-asm.h
@@ -28,6 +28,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #include "auto-host.h"
 
+#define PASTE2(a, b) PASTE2a(a, b)
+#define PASTE2a(a, b) a ## b
+
 /* These macros currently support GNU/Linux, Solaris and Darwin.  */
 
 #ifdef __ELF__
@@ -46,9 +49,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #endif
 
 #ifdef __USER_LABEL_PREFIX__
-# define ASMNAME2(prefix, name)	prefix ## name
-# define ASMNAME1(prefix, name)	ASMNAME2(prefix, name)
-# define ASMNAME(name)		ASMNAME1(__USER_LABEL_PREFIX__, name)
+# define ASMNAME(name)		PASTE2(__USER_LABEL_PREFIX__, name)
 #else
 # define ASMNAME(name)		name
 #endif
@@ -66,15 +67,24 @@ ASMNAME(fn):
 
 #define FUNC_END(fn) FN_SIZE(ASMNAME(fn))
 
-#ifdef __SSE2__
-# ifdef __AVX__
-#  define MOVAPS vmovaps
-# else
-#  define MOVAPS movaps
-# endif
+#ifdef MS2SYSV_STUB_AVX
+# define MS2SYSV_STUB_PREFIX __avx_
+# define MOVAPS vmovaps
+#elif defined(MS2SYSV_STUB_SSE)
+# define MS2SYSV_STUB_PREFIX __sse_
+# define MOVAPS movaps
+#endif
+
+#if defined (MS2SYSV_STUB_PREFIX) && defined (MOVAPS)
+
+# define MS2SYSV_STUB_BEGIN(base_name) \
+	HIDDEN_FUNC(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
+
+# define MS2SYSV_STUB_END(base_name) \
+	FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
 
 /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
-#define SSE_SAVE		   \
+# define SSE_SAVE		   \
 	MOVAPS %xmm15,-0x30(%rax); \
 	MOVAPS %xmm14,-0x20(%rax); \
 	MOVAPS %xmm13,-0x10(%rax); \
@@ -87,7 +97,7 @@ ASMNAME(fn):
 	MOVAPS %xmm6,  0x60(%rax)
 
 /* Restore SSE registers 6-15. off is the offset of rsi to get to xmm6.  */
-#define SSE_RESTORE		    \
+# define SSE_RESTORE		    \
 	MOVAPS -0x30(%rsi), %xmm15; \
 	MOVAPS -0x20(%rsi), %xmm14; \
 	MOVAPS -0x10(%rsi), %xmm13; \
@@ -99,5 +109,5 @@ ASMNAME(fn):
 	MOVAPS  0x50(%rsi), %xmm7 ; \
 	MOVAPS  0x60(%rsi), %xmm6
 
-#endif /* __SSE2__ */
+#endif /* defined (MS2SYSV_STUB_ISA) && defined (MOVAPS) */
 #endif /* I386_ASM_H */
diff --git a/libgcc/config/i386/resms64.S b/libgcc/config/i386/resms64.h
similarity index 76%
rename from libgcc/config/i386/resms64.S
rename to libgcc/config/i386/resms64.h
index f842c20a77a..f01b41897bc 100644
--- a/libgcc/config/i386/resms64.S
+++ b/libgcc/config/i386/resms64.h
@@ -29,29 +29,29 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 /* Epilogue routine for restoring 64-bit ms/sysv registers.  */
 
 	.text
-HIDDEN_FUNC(__resms64_18)
+MS2SYSV_STUB_BEGIN(resms64_18)
 	mov	-0x70(%rsi),%r15
-HIDDEN_FUNC(__resms64_17)
+MS2SYSV_STUB_BEGIN(resms64_17)
 	mov	-0x68(%rsi),%r14
-HIDDEN_FUNC(__resms64_16)
+MS2SYSV_STUB_BEGIN(resms64_16)
 	mov	-0x60(%rsi),%r13
-HIDDEN_FUNC(__resms64_15)
+MS2SYSV_STUB_BEGIN(resms64_15)
 	mov	-0x58(%rsi),%r12
-HIDDEN_FUNC(__resms64_14)
+MS2SYSV_STUB_BEGIN(resms64_14)
 	mov	-0x50(%rsi),%rbp
-HIDDEN_FUNC(__resms64_13)
+MS2SYSV_STUB_BEGIN(resms64_13)
 	mov	-0x48(%rsi),%rbx
-HIDDEN_FUNC(__resms64_12)
+MS2SYSV_STUB_BEGIN(resms64_12)
 	mov	-0x40(%rsi),%rdi
 	SSE_RESTORE
 	mov	-0x38(%rsi),%rsi
 	ret
-FUNC_END(__resms64_12)
-FUNC_END(__resms64_13)
-FUNC_END(__resms64_14)
-FUNC_END(__resms64_15)
-FUNC_END(__resms64_16)
-FUNC_END(__resms64_17)
-FUNC_END(__resms64_18)
+MS2SYSV_STUB_END(resms64_12)
+MS2SYSV_STUB_END(resms64_13)
+MS2SYSV_STUB_END(resms64_14)
+MS2SYSV_STUB_END(resms64_15)
+MS2SYSV_STUB_END(resms64_16)
+MS2SYSV_STUB_END(resms64_17)
+MS2SYSV_STUB_END(resms64_18)
 
 #endif /* __x86_64__ */
diff --git a/libgcc/config/i386/resms64f.S b/libgcc/config/i386/resms64f.h
similarity index 79%
rename from libgcc/config/i386/resms64f.S
rename to libgcc/config/i386/resms64f.h
index 81946cda944..743ec514cef 100644
--- a/libgcc/config/i386/resms64f.S
+++ b/libgcc/config/i386/resms64f.h
@@ -30,26 +30,26 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    pointer is used.  */
 
 	.text
-HIDDEN_FUNC(__resms64f_17)
+MS2SYSV_STUB_BEGIN(resms64f_17)
 	mov	-0x68(%rsi),%r15
-HIDDEN_FUNC(__resms64f_16)
+MS2SYSV_STUB_BEGIN(resms64f_16)
 	mov	-0x60(%rsi),%r14
-HIDDEN_FUNC(__resms64f_15)
+MS2SYSV_STUB_BEGIN(resms64f_15)
 	mov	-0x58(%rsi),%r13
-HIDDEN_FUNC(__resms64f_14)
+MS2SYSV_STUB_BEGIN(resms64f_14)
 	mov	-0x50(%rsi),%r12
-HIDDEN_FUNC(__resms64f_13)
+MS2SYSV_STUB_BEGIN(resms64f_13)
 	mov	-0x48(%rsi),%rbx
-HIDDEN_FUNC(__resms64f_12)
+MS2SYSV_STUB_BEGIN(resms64f_12)
 	mov	-0x40(%rsi),%rdi
 	SSE_RESTORE
 	mov	-0x38(%rsi),%rsi
 	ret
-FUNC_END(__resms64f_12)
-FUNC_END(__resms64f_13)
-FUNC_END(__resms64f_14)
-FUNC_END(__resms64f_15)
-FUNC_END(__resms64f_16)
-FUNC_END(__resms64f_17)
+MS2SYSV_STUB_END(resms64f_12)
+MS2SYSV_STUB_END(resms64f_13)
+MS2SYSV_STUB_END(resms64f_14)
+MS2SYSV_STUB_END(resms64f_15)
+MS2SYSV_STUB_END(resms64f_16)
+MS2SYSV_STUB_END(resms64f_17)
 
 #endif /* __x86_64__ */
diff --git a/libgcc/config/i386/resms64fx.S b/libgcc/config/i386/resms64fx.h
similarity index 79%
rename from libgcc/config/i386/resms64fx.S
rename to libgcc/config/i386/resms64fx.h
index acf34fa0837..965807a1299 100644
--- a/libgcc/config/i386/resms64fx.S
+++ b/libgcc/config/i386/resms64fx.h
@@ -31,27 +31,27 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
  * from the function.  */
 
 	.text
-HIDDEN_FUNC(__resms64fx_17)
+MS2SYSV_STUB_BEGIN(resms64fx_17)
 	mov	-0x68(%rsi),%r15
-HIDDEN_FUNC(__resms64fx_16)
+MS2SYSV_STUB_BEGIN(resms64fx_16)
 	mov	-0x60(%rsi),%r14
-HIDDEN_FUNC(__resms64fx_15)
+MS2SYSV_STUB_BEGIN(resms64fx_15)
 	mov	-0x58(%rsi),%r13
-HIDDEN_FUNC(__resms64fx_14)
+MS2SYSV_STUB_BEGIN(resms64fx_14)
 	mov	-0x50(%rsi),%r12
-HIDDEN_FUNC(__resms64fx_13)
+MS2SYSV_STUB_BEGIN(resms64fx_13)
 	mov	-0x48(%rsi),%rbx
-HIDDEN_FUNC(__resms64fx_12)
+MS2SYSV_STUB_BEGIN(resms64fx_12)
 	mov	-0x40(%rsi),%rdi
 	SSE_RESTORE
 	mov	-0x38(%rsi),%rsi
 	leaveq
 	ret
-FUNC_END(__resms64fx_12)
-FUNC_END(__resms64fx_13)
-FUNC_END(__resms64fx_14)
-FUNC_END(__resms64fx_15)
-FUNC_END(__resms64fx_16)
-FUNC_END(__resms64fx_17)
+MS2SYSV_STUB_END(resms64fx_12)
+MS2SYSV_STUB_END(resms64fx_13)
+MS2SYSV_STUB_END(resms64fx_14)
+MS2SYSV_STUB_END(resms64fx_15)
+MS2SYSV_STUB_END(resms64fx_16)
+MS2SYSV_STUB_END(resms64fx_17)
 
 #endif /* __x86_64__ */
diff --git a/libgcc/config/i386/resms64x.S b/libgcc/config/i386/resms64x.h
similarity index 77%
rename from libgcc/config/i386/resms64x.S
rename to libgcc/config/i386/resms64x.h
index e27aab7d881..689a1dec20b 100644
--- a/libgcc/config/i386/resms64x.S
+++ b/libgcc/config/i386/resms64x.h
@@ -30,30 +30,30 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
  * function.  */
 
 	.text
-HIDDEN_FUNC(__resms64x_18)
+MS2SYSV_STUB_BEGIN(resms64x_18)
 	mov	-0x70(%rsi),%r15
-HIDDEN_FUNC(__resms64x_17)
+MS2SYSV_STUB_BEGIN(resms64x_17)
 	mov	-0x68(%rsi),%r14
-HIDDEN_FUNC(__resms64x_16)
+MS2SYSV_STUB_BEGIN(resms64x_16)
 	mov	-0x60(%rsi),%r13
-HIDDEN_FUNC(__resms64x_15)
+MS2SYSV_STUB_BEGIN(resms64x_15)
 	mov	-0x58(%rsi),%r12
-HIDDEN_FUNC(__resms64x_14)
+MS2SYSV_STUB_BEGIN(resms64x_14)
 	mov	-0x50(%rsi),%rbp
-HIDDEN_FUNC(__resms64x_13)
+MS2SYSV_STUB_BEGIN(resms64x_13)
 	mov	-0x48(%rsi),%rbx
-HIDDEN_FUNC(__resms64x_12)
+MS2SYSV_STUB_BEGIN(resms64x_12)
 	mov	-0x40(%rsi),%rdi
 	SSE_RESTORE
 	mov	-0x38(%rsi),%rsi
 	mov	%r10,%rsp
 	ret
-FUNC_END(__resms64x_12)
-FUNC_END(__resms64x_13)
-FUNC_END(__resms64x_14)
-FUNC_END(__resms64x_15)
-FUNC_END(__resms64x_16)
-FUNC_END(__resms64x_17)
-FUNC_END(__resms64x_18)
+MS2SYSV_STUB_END(resms64x_12)
+MS2SYSV_STUB_END(resms64x_13)
+MS2SYSV_STUB_END(resms64x_14)
+MS2SYSV_STUB_END(resms64x_15)
+MS2SYSV_STUB_END(resms64x_16)
+MS2SYSV_STUB_END(resms64x_17)
+MS2SYSV_STUB_END(resms64x_18)
 
 #endif /* __x86_64__ */
diff --git a/libgcc/config/i386/savms64.S b/libgcc/config/i386/savms64.h
similarity index 76%
rename from libgcc/config/i386/savms64.S
rename to libgcc/config/i386/savms64.h
index 44dda46ec54..28d5e3548ab 100644
--- a/libgcc/config/i386/savms64.S
+++ b/libgcc/config/i386/savms64.h
@@ -29,29 +29,29 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 /* Prologue routine for saving 64-bit ms/sysv registers.  */
 
 	.text
-HIDDEN_FUNC(__savms64_18)
+MS2SYSV_STUB_BEGIN(savms64_18)
 	mov	%r15,-0x70(%rax)
-HIDDEN_FUNC(__savms64_17)
+MS2SYSV_STUB_BEGIN(savms64_17)
 	mov	%r14,-0x68(%rax)
-HIDDEN_FUNC(__savms64_16)
+MS2SYSV_STUB_BEGIN(savms64_16)
 	mov	%r13,-0x60(%rax)
-HIDDEN_FUNC(__savms64_15)
+MS2SYSV_STUB_BEGIN(savms64_15)
 	mov	%r12,-0x58(%rax)
-HIDDEN_FUNC(__savms64_14)
+MS2SYSV_STUB_BEGIN(savms64_14)
 	mov	%rbp,-0x50(%rax)
-HIDDEN_FUNC(__savms64_13)
+MS2SYSV_STUB_BEGIN(savms64_13)
 	mov	%rbx,-0x48(%rax)
-HIDDEN_FUNC(__savms64_12)
+MS2SYSV_STUB_BEGIN(savms64_12)
 	mov	%rdi,-0x40(%rax)
 	mov	%rsi,-0x38(%rax)
 	SSE_SAVE
 	ret
-FUNC_END(__savms64_12)
-FUNC_END(__savms64_13)
-FUNC_END(__savms64_14)
-FUNC_END(__savms64_15)
-FUNC_END(__savms64_16)
-FUNC_END(__savms64_17)
-FUNC_END(__savms64_18)
+MS2SYSV_STUB_END(savms64_12)
+MS2SYSV_STUB_END(savms64_13)
+MS2SYSV_STUB_END(savms64_14)
+MS2SYSV_STUB_END(savms64_15)
+MS2SYSV_STUB_END(savms64_16)
+MS2SYSV_STUB_END(savms64_17)
+MS2SYSV_STUB_END(savms64_18)
 
 #endif /* __x86_64__ */
diff --git a/libgcc/config/i386/savms64f.S b/libgcc/config/i386/savms64f.h
similarity index 79%
rename from libgcc/config/i386/savms64f.S
rename to libgcc/config/i386/savms64f.h
index 64e91ac0394..723e1080f5c 100644
--- a/libgcc/config/i386/savms64f.S
+++ b/libgcc/config/i386/savms64f.h
@@ -30,26 +30,26 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
  * needed or hard frame pointer used.  */
 
 	.text
-HIDDEN_FUNC(__savms64f_17)
+MS2SYSV_STUB_BEGIN(savms64f_17)
 	mov	%r15,-0x68(%rax)
-HIDDEN_FUNC(__savms64f_16)
+MS2SYSV_STUB_BEGIN(savms64f_16)
 	mov	%r14,-0x60(%rax)
-HIDDEN_FUNC(__savms64f_15)
+MS2SYSV_STUB_BEGIN(savms64f_15)
 	mov	%r13,-0x58(%rax)
-HIDDEN_FUNC(__savms64f_14)
+MS2SYSV_STUB_BEGIN(savms64f_14)
 	mov	%r12,-0x50(%rax)
-HIDDEN_FUNC(__savms64f_13)
+MS2SYSV_STUB_BEGIN(savms64f_13)
 	mov	%rbx,-0x48(%rax)
-HIDDEN_FUNC(__savms64f_12)
+MS2SYSV_STUB_BEGIN(savms64f_12)
 	mov	%rdi,-0x40(%rax)
 	mov	%rsi,-0x38(%rax)
 	SSE_SAVE
 	ret
-FUNC_END(__savms64f_12)
-FUNC_END(__savms64f_13)
-FUNC_END(__savms64f_14)
-FUNC_END(__savms64f_15)
-FUNC_END(__savms64f_16)
-FUNC_END(__savms64f_17)
+MS2SYSV_STUB_END(savms64f_12)
+MS2SYSV_STUB_END(savms64f_13)
+MS2SYSV_STUB_END(savms64f_14)
+MS2SYSV_STUB_END(savms64f_15)
+MS2SYSV_STUB_END(savms64f_16)
+MS2SYSV_STUB_END(savms64f_17)
 
 #endif /* __x86_64__ */
diff --git a/libgcc/config/i386/sse_resms64.S b/libgcc/config/i386/sse_resms64.S
new file mode 100644
index 00000000000..c87f5cc021d
--- /dev/null
+++ b/libgcc/config/i386/sse_resms64.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_SSE
+#include "resms64.h"
diff --git a/libgcc/config/i386/sse_resms64f.S b/libgcc/config/i386/sse_resms64f.S
new file mode 100644
index 00000000000..3a066bc174a
--- /dev/null
+++ b/libgcc/config/i386/sse_resms64f.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_SSE
+#include "resms64f.h"
diff --git a/libgcc/config/i386/sse_resms64fx.S b/libgcc/config/i386/sse_resms64fx.S
new file mode 100644
index 00000000000..142667a28bf
--- /dev/null
+++ b/libgcc/config/i386/sse_resms64fx.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_SSE
+#include "resms64fx.h"
diff --git a/libgcc/config/i386/sse_resms64x.S b/libgcc/config/i386/sse_resms64x.S
new file mode 100644
index 00000000000..2cfc2b0195f
--- /dev/null
+++ b/libgcc/config/i386/sse_resms64x.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_SSE
+#include "resms64x.h"
diff --git a/libgcc/config/i386/sse_savms64.S b/libgcc/config/i386/sse_savms64.S
new file mode 100644
index 00000000000..52f43075b40
--- /dev/null
+++ b/libgcc/config/i386/sse_savms64.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_SSE
+#include "savms64.h"
diff --git a/libgcc/config/i386/sse_savms64f.S b/libgcc/config/i386/sse_savms64f.S
new file mode 100644
index 00000000000..426be35b53b
--- /dev/null
+++ b/libgcc/config/i386/sse_savms64f.S
@@ -0,0 +1,2 @@
+#define MS2SYSV_STUB_SSE
+#include "savms64f.h"
diff --git a/libgcc/config/i386/t-msabi b/libgcc/config/i386/t-msabi
index f9806a611aa..ffc9c4f6656 100644
--- a/libgcc/config/i386/t-msabi
+++ b/libgcc/config/i386/t-msabi
@@ -1,7 +1,13 @@
 # Makefile fragment to support -mcall-ms2sysv-xlogues
-LIB2ADD_ST += $(srcdir)/config/i386/savms64.S \
-	      $(srcdir)/config/i386/resms64.S \
-	      $(srcdir)/config/i386/resms64x.S \
-	      $(srcdir)/config/i386/savms64f.S \
-	      $(srcdir)/config/i386/resms64f.S \
-	      $(srcdir)/config/i386/resms64fx.S
+LIB2ADD_ST += $(srcdir)/config/i386/avx_savms64.S \
+	      $(srcdir)/config/i386/avx_resms64.S \
+	      $(srcdir)/config/i386/avx_resms64x.S \
+	      $(srcdir)/config/i386/avx_savms64f.S \
+	      $(srcdir)/config/i386/avx_resms64f.S \
+	      $(srcdir)/config/i386/avx_resms64fx.S \
+	      $(srcdir)/config/i386/sse_savms64.S \
+	      $(srcdir)/config/i386/sse_resms64.S \
+	      $(srcdir)/config/i386/sse_resms64x.S \
+	      $(srcdir)/config/i386/sse_savms64f.S \
+	      $(srcdir)/config/i386/sse_resms64f.S \
+	      $(srcdir)/config/i386/sse_resms64fx.S
-- 
2.14.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-14  3:57 [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV Daniel Santos
@ 2017-09-17 15:53 ` Uros Bizjak
  2017-09-17 21:56   ` Daniel Santos
  0 siblings, 1 reply; 20+ messages in thread
From: Uros Bizjak @ 2017-09-17 15:53 UTC (permalink / raw)
  To: Daniel Santos
  Cc: gcc-patches, Jan Hubicka, Ian Lance Taylor, Rainer Orth, Mike Stump

On Thu, Sep 14, 2017 at 6:03 AM, Daniel Santos <daniel.santos@pobox.com> wrote:
> I made a silly mistake in libgcc by testing the cpp macro __AVX__ to
> determine rather to use movaps or vmovaps in the stubs.  This resulted
> in the stubs choice of instruction being decided by the machine flags
> when the compiler was built rather than those being supplied at the
> command line.  This patch splits stubs into separate sse and avx
> versions so that both are available.
>
> gcc:
>         config/i386/i386.c: (xlogue_layout::STUB_NAME_MAX_LEN): Increase to 20
>         bytes.
>         (xlogue_layout::s_stub_names): Add an additional size-2 diminsion.
>         (xlogue_layout::get_stub_name): Modify to select the appropairate sse
>         and avx version of the stub.
>
> gcc/testsuite:
>         gcc.target/i386/pr82196-1.c: New test.
>         gcc.target/i386/pr82196-2.c: Likewise.
>
> libgcc:
>         config/i386/i386-asm.h (PASTE2): New macro.
>         (ASMNAME): Modify to use PASTE2.
>         (MS2SYSV_STUB_PREFIX): New macro for isa prefix.
>         (MS2SYSV_STUB_BEGIN, MS2SYSV_STUB_END): New macros for stub headers.
>         config/i386/resms64.S: Rename to a header file, use MS2SYSV_STUB_BEGIN
>         instead of HIDDEN_FUNC and MS2SYSV_STUB_END instead of FUNC_END.
>         config/i386/resms64f.S: Likewise.
>         config/i386/resms64fx.S: Likewise.
>         config/i386/resms64x.S: Likewise.
>         config/i386/savms64.S: Likewise.
>         config/i386/savms64f.S: Likewise.
>         config/i386/avx_resms64.S: New file that only defines a macro and
>         includes it's corresponding header file.
>         config/i386/avx_resms64f.S: Likewise.
>         config/i386/avx_resms64fx.S: Likewise.
>         config/i386/avx_resms64x.S: Likewise.
>         config/i386/avx_savms64.S: Likewise.
>         config/i386/avx_savms64f.S: Likewise.
>         config/i386/sse_resms64.S: Likewise.
>         config/i386/sse_resms64f.S: Likewise.
>         config/i386/sse_resms64fx.S: Likewise.
>         config/i386/sse_resms64x.S: Likewise.
>         config/i386/sse_savms64.S: Likewise.
>         config/i386/sse_savms64f.S: Likewise.
>         config/i386/t-msabi: Modified to add avx and sse versions of stubs.

OK.

Thanks,
Uros.

> Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
> ---
>  gcc/config/i386/i386.c                          | 15 ++++++-----
>  gcc/testsuite/gcc.target/i386/pr82196-1.c       | 14 ++++++++++
>  gcc/testsuite/gcc.target/i386/pr82196-2.c       | 14 ++++++++++
>  libgcc/config/i386/avx_resms64.S                |  2 ++
>  libgcc/config/i386/avx_resms64f.S               |  2 ++
>  libgcc/config/i386/avx_resms64fx.S              |  2 ++
>  libgcc/config/i386/avx_resms64x.S               |  2 ++
>  libgcc/config/i386/avx_savms64.S                |  2 ++
>  libgcc/config/i386/avx_savms64f.S               |  2 ++
>  libgcc/config/i386/i386-asm.h                   | 34 ++++++++++++++++---------
>  libgcc/config/i386/{resms64.S => resms64.h}     | 28 ++++++++++----------
>  libgcc/config/i386/{resms64f.S => resms64f.h}   | 24 ++++++++---------
>  libgcc/config/i386/{resms64fx.S => resms64fx.h} | 24 ++++++++---------
>  libgcc/config/i386/{resms64x.S => resms64x.h}   | 28 ++++++++++----------
>  libgcc/config/i386/{savms64.S => savms64.h}     | 28 ++++++++++----------
>  libgcc/config/i386/{savms64f.S => savms64f.h}   | 24 ++++++++---------
>  libgcc/config/i386/sse_resms64.S                |  2 ++
>  libgcc/config/i386/sse_resms64f.S               |  2 ++
>  libgcc/config/i386/sse_resms64fx.S              |  2 ++
>  libgcc/config/i386/sse_resms64x.S               |  2 ++
>  libgcc/config/i386/sse_savms64.S                |  2 ++
>  libgcc/config/i386/sse_savms64f.S               |  2 ++
>  libgcc/config/i386/t-msabi                      | 18 ++++++++-----
>  23 files changed, 173 insertions(+), 102 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr82196-1.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr82196-2.c
>  create mode 100644 libgcc/config/i386/avx_resms64.S
>  create mode 100644 libgcc/config/i386/avx_resms64f.S
>  create mode 100644 libgcc/config/i386/avx_resms64fx.S
>  create mode 100644 libgcc/config/i386/avx_resms64x.S
>  create mode 100644 libgcc/config/i386/avx_savms64.S
>  create mode 100644 libgcc/config/i386/avx_savms64f.S
>  rename libgcc/config/i386/{resms64.S => resms64.h} (76%)
>  rename libgcc/config/i386/{resms64f.S => resms64f.h} (79%)
>  rename libgcc/config/i386/{resms64fx.S => resms64fx.h} (79%)
>  rename libgcc/config/i386/{resms64x.S => resms64x.h} (77%)
>  rename libgcc/config/i386/{savms64.S => savms64.h} (76%)
>  rename libgcc/config/i386/{savms64f.S => savms64f.h} (79%)
>  create mode 100644 libgcc/config/i386/sse_resms64.S
>  create mode 100644 libgcc/config/i386/sse_resms64f.S
>  create mode 100644 libgcc/config/i386/sse_resms64fx.S
>  create mode 100644 libgcc/config/i386/sse_resms64x.S
>  create mode 100644 libgcc/config/i386/sse_savms64.S
>  create mode 100644 libgcc/config/i386/sse_savms64f.S
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index b2b02acc58a..f0d7d0eb196 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -2513,7 +2513,7 @@ public:
>    static const unsigned MAX_REGS = 18;
>    static const unsigned MAX_EXTRA_REGS = MAX_REGS - MIN_REGS;
>    static const unsigned VARIANT_COUNT = MAX_EXTRA_REGS + 1;
> -  static const unsigned STUB_NAME_MAX_LEN = 16;
> +  static const unsigned STUB_NAME_MAX_LEN = 20;
>    static const char * const STUB_BASE_NAMES[XLOGUE_STUB_COUNT];
>    static const unsigned REG_ORDER[MAX_REGS];
>    static const unsigned REG_ORDER_REALIGN[MAX_REGS];
> @@ -2536,7 +2536,7 @@ private:
>    struct reginfo m_regs[MAX_REGS];
>
>    /* Lazy-inited cache of symbol names for stubs.  */
> -  static char s_stub_names[XLOGUE_STUB_COUNT][VARIANT_COUNT]
> +  static char s_stub_names[2][XLOGUE_STUB_COUNT][VARIANT_COUNT]
>                           [STUB_NAME_MAX_LEN];
>
>    static const xlogue_layout s_instances[XLOGUE_SET_COUNT];
> @@ -2588,7 +2588,7 @@ const unsigned xlogue_layout::VARIANT_COUNT;
>  const unsigned xlogue_layout::STUB_NAME_MAX_LEN;
>
>  /* Initialize xlogue_layout::s_stub_names to zero.  */
> -char xlogue_layout::s_stub_names[XLOGUE_STUB_COUNT][VARIANT_COUNT]
> +char xlogue_layout::s_stub_names[2][XLOGUE_STUB_COUNT][VARIANT_COUNT]
>                                 [STUB_NAME_MAX_LEN];
>
>  /* Instantiates all xlogue_layout instances.  */
> @@ -2692,13 +2692,16 @@ const char *
>  xlogue_layout::get_stub_name (enum xlogue_stub stub,
>                               unsigned n_extra_regs)
>  {
> -  char *name = s_stub_names[stub][n_extra_regs];
> +  const int have_avx = TARGET_AVX;
> +  char *name = s_stub_names[!!have_avx][stub][n_extra_regs];
>
>    /* Lazy init */
>    if (!*name)
>      {
> -      int res = snprintf (name, STUB_NAME_MAX_LEN, "__%s_%u",
> -                         STUB_BASE_NAMES[stub], MIN_REGS + n_extra_regs);
> +      int res = snprintf (name, STUB_NAME_MAX_LEN, "__%s_%s_%u",
> +                         (have_avx ? "avx" : "sse"),
> +                         STUB_BASE_NAMES[stub],
> +                         MIN_REGS + n_extra_regs);
>        gcc_checking_assert (res < (int)STUB_NAME_MAX_LEN);
>      }
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr82196-1.c b/gcc/testsuite/gcc.target/i386/pr82196-1.c
> new file mode 100644
> index 00000000000..fa573dc6b66
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
> @@ -0,0 +1,14 @@
> +/* { dg-do compile } */
> +/* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
> +/* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
> +/* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
> +
> +void __attribute__((sysv_abi)) a() {
> +}
> +
> +static void __attribute__((sysv_abi)) (*volatile a_noinfo)() = a;
> +
> +void __attribute__((ms_abi)) b() {
> +  __asm__ __volatile__ ("" :::"rbx", "rbp", "r12", "r13", "r14", "r15");
> +  a_noinfo ();
> +}
> diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c b/gcc/testsuite/gcc.target/i386/pr82196-2.c
> new file mode 100644
> index 00000000000..31705bee29b
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
> @@ -0,0 +1,14 @@
> +/* { dg-do compile } */
> +/* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
> +/* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
> +/* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */
> +
> +void __attribute__((sysv_abi)) a() {
> +}
> +
> +static void __attribute__((sysv_abi)) (*volatile a_noinfo)() = a;
> +
> +void __attribute__((ms_abi)) b() {
> +  __asm__ __volatile__ ("" :::"rbx", "rbp", "r12", "r13", "r14", "r15");
> +  a_noinfo ();
> +}
> diff --git a/libgcc/config/i386/avx_resms64.S b/libgcc/config/i386/avx_resms64.S
> new file mode 100644
> index 00000000000..2be744937cf
> --- /dev/null
> +++ b/libgcc/config/i386/avx_resms64.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_AVX
> +#include "resms64.h"
> diff --git a/libgcc/config/i386/avx_resms64f.S b/libgcc/config/i386/avx_resms64f.S
> new file mode 100644
> index 00000000000..76a1340ab1f
> --- /dev/null
> +++ b/libgcc/config/i386/avx_resms64f.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_AVX
> +#include "resms64f.h"
> diff --git a/libgcc/config/i386/avx_resms64fx.S b/libgcc/config/i386/avx_resms64fx.S
> new file mode 100644
> index 00000000000..2ea4738af7e
> --- /dev/null
> +++ b/libgcc/config/i386/avx_resms64fx.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_AVX
> +#include "resms64fx.h"
> diff --git a/libgcc/config/i386/avx_resms64x.S b/libgcc/config/i386/avx_resms64x.S
> new file mode 100644
> index 00000000000..14a53d4fcf9
> --- /dev/null
> +++ b/libgcc/config/i386/avx_resms64x.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_AVX
> +#include "resms64x.h"
> diff --git a/libgcc/config/i386/avx_savms64.S b/libgcc/config/i386/avx_savms64.S
> new file mode 100644
> index 00000000000..fed1620b968
> --- /dev/null
> +++ b/libgcc/config/i386/avx_savms64.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_AVX
> +#include "savms64.h"
> diff --git a/libgcc/config/i386/avx_savms64f.S b/libgcc/config/i386/avx_savms64f.S
> new file mode 100644
> index 00000000000..32279657e30
> --- /dev/null
> +++ b/libgcc/config/i386/avx_savms64f.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_AVX
> +#include "savms64f.h"
> diff --git a/libgcc/config/i386/i386-asm.h b/libgcc/config/i386/i386-asm.h
> index 1387fd24b4f..424e0f72aac 100644
> --- a/libgcc/config/i386/i386-asm.h
> +++ b/libgcc/config/i386/i386-asm.h
> @@ -28,6 +28,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>
>  #include "auto-host.h"
>
> +#define PASTE2(a, b) PASTE2a(a, b)
> +#define PASTE2a(a, b) a ## b
> +
>  /* These macros currently support GNU/Linux, Solaris and Darwin.  */
>
>  #ifdef __ELF__
> @@ -46,9 +49,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>  #endif
>
>  #ifdef __USER_LABEL_PREFIX__
> -# define ASMNAME2(prefix, name)        prefix ## name
> -# define ASMNAME1(prefix, name)        ASMNAME2(prefix, name)
> -# define ASMNAME(name)         ASMNAME1(__USER_LABEL_PREFIX__, name)
> +# define ASMNAME(name)         PASTE2(__USER_LABEL_PREFIX__, name)
>  #else
>  # define ASMNAME(name)         name
>  #endif
> @@ -66,15 +67,24 @@ ASMNAME(fn):
>
>  #define FUNC_END(fn) FN_SIZE(ASMNAME(fn))
>
> -#ifdef __SSE2__
> -# ifdef __AVX__
> -#  define MOVAPS vmovaps
> -# else
> -#  define MOVAPS movaps
> -# endif
> +#ifdef MS2SYSV_STUB_AVX
> +# define MS2SYSV_STUB_PREFIX __avx_
> +# define MOVAPS vmovaps
> +#elif defined(MS2SYSV_STUB_SSE)
> +# define MS2SYSV_STUB_PREFIX __sse_
> +# define MOVAPS movaps
> +#endif
> +
> +#if defined (MS2SYSV_STUB_PREFIX) && defined (MOVAPS)
> +
> +# define MS2SYSV_STUB_BEGIN(base_name) \
> +       HIDDEN_FUNC(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
> +
> +# define MS2SYSV_STUB_END(base_name) \
> +       FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
>
>  /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
> -#define SSE_SAVE                  \
> +# define SSE_SAVE                 \
>         MOVAPS %xmm15,-0x30(%rax); \
>         MOVAPS %xmm14,-0x20(%rax); \
>         MOVAPS %xmm13,-0x10(%rax); \
> @@ -87,7 +97,7 @@ ASMNAME(fn):
>         MOVAPS %xmm6,  0x60(%rax)
>
>  /* Restore SSE registers 6-15. off is the offset of rsi to get to xmm6.  */
> -#define SSE_RESTORE                \
> +# define SSE_RESTORE               \
>         MOVAPS -0x30(%rsi), %xmm15; \
>         MOVAPS -0x20(%rsi), %xmm14; \
>         MOVAPS -0x10(%rsi), %xmm13; \
> @@ -99,5 +109,5 @@ ASMNAME(fn):
>         MOVAPS  0x50(%rsi), %xmm7 ; \
>         MOVAPS  0x60(%rsi), %xmm6
>
> -#endif /* __SSE2__ */
> +#endif /* defined (MS2SYSV_STUB_ISA) && defined (MOVAPS) */
>  #endif /* I386_ASM_H */
> diff --git a/libgcc/config/i386/resms64.S b/libgcc/config/i386/resms64.h
> similarity index 76%
> rename from libgcc/config/i386/resms64.S
> rename to libgcc/config/i386/resms64.h
> index f842c20a77a..f01b41897bc 100644
> --- a/libgcc/config/i386/resms64.S
> +++ b/libgcc/config/i386/resms64.h
> @@ -29,29 +29,29 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>  /* Epilogue routine for restoring 64-bit ms/sysv registers.  */
>
>         .text
> -HIDDEN_FUNC(__resms64_18)
> +MS2SYSV_STUB_BEGIN(resms64_18)
>         mov     -0x70(%rsi),%r15
> -HIDDEN_FUNC(__resms64_17)
> +MS2SYSV_STUB_BEGIN(resms64_17)
>         mov     -0x68(%rsi),%r14
> -HIDDEN_FUNC(__resms64_16)
> +MS2SYSV_STUB_BEGIN(resms64_16)
>         mov     -0x60(%rsi),%r13
> -HIDDEN_FUNC(__resms64_15)
> +MS2SYSV_STUB_BEGIN(resms64_15)
>         mov     -0x58(%rsi),%r12
> -HIDDEN_FUNC(__resms64_14)
> +MS2SYSV_STUB_BEGIN(resms64_14)
>         mov     -0x50(%rsi),%rbp
> -HIDDEN_FUNC(__resms64_13)
> +MS2SYSV_STUB_BEGIN(resms64_13)
>         mov     -0x48(%rsi),%rbx
> -HIDDEN_FUNC(__resms64_12)
> +MS2SYSV_STUB_BEGIN(resms64_12)
>         mov     -0x40(%rsi),%rdi
>         SSE_RESTORE
>         mov     -0x38(%rsi),%rsi
>         ret
> -FUNC_END(__resms64_12)
> -FUNC_END(__resms64_13)
> -FUNC_END(__resms64_14)
> -FUNC_END(__resms64_15)
> -FUNC_END(__resms64_16)
> -FUNC_END(__resms64_17)
> -FUNC_END(__resms64_18)
> +MS2SYSV_STUB_END(resms64_12)
> +MS2SYSV_STUB_END(resms64_13)
> +MS2SYSV_STUB_END(resms64_14)
> +MS2SYSV_STUB_END(resms64_15)
> +MS2SYSV_STUB_END(resms64_16)
> +MS2SYSV_STUB_END(resms64_17)
> +MS2SYSV_STUB_END(resms64_18)
>
>  #endif /* __x86_64__ */
> diff --git a/libgcc/config/i386/resms64f.S b/libgcc/config/i386/resms64f.h
> similarity index 79%
> rename from libgcc/config/i386/resms64f.S
> rename to libgcc/config/i386/resms64f.h
> index 81946cda944..743ec514cef 100644
> --- a/libgcc/config/i386/resms64f.S
> +++ b/libgcc/config/i386/resms64f.h
> @@ -30,26 +30,26 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>     pointer is used.  */
>
>         .text
> -HIDDEN_FUNC(__resms64f_17)
> +MS2SYSV_STUB_BEGIN(resms64f_17)
>         mov     -0x68(%rsi),%r15
> -HIDDEN_FUNC(__resms64f_16)
> +MS2SYSV_STUB_BEGIN(resms64f_16)
>         mov     -0x60(%rsi),%r14
> -HIDDEN_FUNC(__resms64f_15)
> +MS2SYSV_STUB_BEGIN(resms64f_15)
>         mov     -0x58(%rsi),%r13
> -HIDDEN_FUNC(__resms64f_14)
> +MS2SYSV_STUB_BEGIN(resms64f_14)
>         mov     -0x50(%rsi),%r12
> -HIDDEN_FUNC(__resms64f_13)
> +MS2SYSV_STUB_BEGIN(resms64f_13)
>         mov     -0x48(%rsi),%rbx
> -HIDDEN_FUNC(__resms64f_12)
> +MS2SYSV_STUB_BEGIN(resms64f_12)
>         mov     -0x40(%rsi),%rdi
>         SSE_RESTORE
>         mov     -0x38(%rsi),%rsi
>         ret
> -FUNC_END(__resms64f_12)
> -FUNC_END(__resms64f_13)
> -FUNC_END(__resms64f_14)
> -FUNC_END(__resms64f_15)
> -FUNC_END(__resms64f_16)
> -FUNC_END(__resms64f_17)
> +MS2SYSV_STUB_END(resms64f_12)
> +MS2SYSV_STUB_END(resms64f_13)
> +MS2SYSV_STUB_END(resms64f_14)
> +MS2SYSV_STUB_END(resms64f_15)
> +MS2SYSV_STUB_END(resms64f_16)
> +MS2SYSV_STUB_END(resms64f_17)
>
>  #endif /* __x86_64__ */
> diff --git a/libgcc/config/i386/resms64fx.S b/libgcc/config/i386/resms64fx.h
> similarity index 79%
> rename from libgcc/config/i386/resms64fx.S
> rename to libgcc/config/i386/resms64fx.h
> index acf34fa0837..965807a1299 100644
> --- a/libgcc/config/i386/resms64fx.S
> +++ b/libgcc/config/i386/resms64fx.h
> @@ -31,27 +31,27 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>   * from the function.  */
>
>         .text
> -HIDDEN_FUNC(__resms64fx_17)
> +MS2SYSV_STUB_BEGIN(resms64fx_17)
>         mov     -0x68(%rsi),%r15
> -HIDDEN_FUNC(__resms64fx_16)
> +MS2SYSV_STUB_BEGIN(resms64fx_16)
>         mov     -0x60(%rsi),%r14
> -HIDDEN_FUNC(__resms64fx_15)
> +MS2SYSV_STUB_BEGIN(resms64fx_15)
>         mov     -0x58(%rsi),%r13
> -HIDDEN_FUNC(__resms64fx_14)
> +MS2SYSV_STUB_BEGIN(resms64fx_14)
>         mov     -0x50(%rsi),%r12
> -HIDDEN_FUNC(__resms64fx_13)
> +MS2SYSV_STUB_BEGIN(resms64fx_13)
>         mov     -0x48(%rsi),%rbx
> -HIDDEN_FUNC(__resms64fx_12)
> +MS2SYSV_STUB_BEGIN(resms64fx_12)
>         mov     -0x40(%rsi),%rdi
>         SSE_RESTORE
>         mov     -0x38(%rsi),%rsi
>         leaveq
>         ret
> -FUNC_END(__resms64fx_12)
> -FUNC_END(__resms64fx_13)
> -FUNC_END(__resms64fx_14)
> -FUNC_END(__resms64fx_15)
> -FUNC_END(__resms64fx_16)
> -FUNC_END(__resms64fx_17)
> +MS2SYSV_STUB_END(resms64fx_12)
> +MS2SYSV_STUB_END(resms64fx_13)
> +MS2SYSV_STUB_END(resms64fx_14)
> +MS2SYSV_STUB_END(resms64fx_15)
> +MS2SYSV_STUB_END(resms64fx_16)
> +MS2SYSV_STUB_END(resms64fx_17)
>
>  #endif /* __x86_64__ */
> diff --git a/libgcc/config/i386/resms64x.S b/libgcc/config/i386/resms64x.h
> similarity index 77%
> rename from libgcc/config/i386/resms64x.S
> rename to libgcc/config/i386/resms64x.h
> index e27aab7d881..689a1dec20b 100644
> --- a/libgcc/config/i386/resms64x.S
> +++ b/libgcc/config/i386/resms64x.h
> @@ -30,30 +30,30 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>   * function.  */
>
>         .text
> -HIDDEN_FUNC(__resms64x_18)
> +MS2SYSV_STUB_BEGIN(resms64x_18)
>         mov     -0x70(%rsi),%r15
> -HIDDEN_FUNC(__resms64x_17)
> +MS2SYSV_STUB_BEGIN(resms64x_17)
>         mov     -0x68(%rsi),%r14
> -HIDDEN_FUNC(__resms64x_16)
> +MS2SYSV_STUB_BEGIN(resms64x_16)
>         mov     -0x60(%rsi),%r13
> -HIDDEN_FUNC(__resms64x_15)
> +MS2SYSV_STUB_BEGIN(resms64x_15)
>         mov     -0x58(%rsi),%r12
> -HIDDEN_FUNC(__resms64x_14)
> +MS2SYSV_STUB_BEGIN(resms64x_14)
>         mov     -0x50(%rsi),%rbp
> -HIDDEN_FUNC(__resms64x_13)
> +MS2SYSV_STUB_BEGIN(resms64x_13)
>         mov     -0x48(%rsi),%rbx
> -HIDDEN_FUNC(__resms64x_12)
> +MS2SYSV_STUB_BEGIN(resms64x_12)
>         mov     -0x40(%rsi),%rdi
>         SSE_RESTORE
>         mov     -0x38(%rsi),%rsi
>         mov     %r10,%rsp
>         ret
> -FUNC_END(__resms64x_12)
> -FUNC_END(__resms64x_13)
> -FUNC_END(__resms64x_14)
> -FUNC_END(__resms64x_15)
> -FUNC_END(__resms64x_16)
> -FUNC_END(__resms64x_17)
> -FUNC_END(__resms64x_18)
> +MS2SYSV_STUB_END(resms64x_12)
> +MS2SYSV_STUB_END(resms64x_13)
> +MS2SYSV_STUB_END(resms64x_14)
> +MS2SYSV_STUB_END(resms64x_15)
> +MS2SYSV_STUB_END(resms64x_16)
> +MS2SYSV_STUB_END(resms64x_17)
> +MS2SYSV_STUB_END(resms64x_18)
>
>  #endif /* __x86_64__ */
> diff --git a/libgcc/config/i386/savms64.S b/libgcc/config/i386/savms64.h
> similarity index 76%
> rename from libgcc/config/i386/savms64.S
> rename to libgcc/config/i386/savms64.h
> index 44dda46ec54..28d5e3548ab 100644
> --- a/libgcc/config/i386/savms64.S
> +++ b/libgcc/config/i386/savms64.h
> @@ -29,29 +29,29 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>  /* Prologue routine for saving 64-bit ms/sysv registers.  */
>
>         .text
> -HIDDEN_FUNC(__savms64_18)
> +MS2SYSV_STUB_BEGIN(savms64_18)
>         mov     %r15,-0x70(%rax)
> -HIDDEN_FUNC(__savms64_17)
> +MS2SYSV_STUB_BEGIN(savms64_17)
>         mov     %r14,-0x68(%rax)
> -HIDDEN_FUNC(__savms64_16)
> +MS2SYSV_STUB_BEGIN(savms64_16)
>         mov     %r13,-0x60(%rax)
> -HIDDEN_FUNC(__savms64_15)
> +MS2SYSV_STUB_BEGIN(savms64_15)
>         mov     %r12,-0x58(%rax)
> -HIDDEN_FUNC(__savms64_14)
> +MS2SYSV_STUB_BEGIN(savms64_14)
>         mov     %rbp,-0x50(%rax)
> -HIDDEN_FUNC(__savms64_13)
> +MS2SYSV_STUB_BEGIN(savms64_13)
>         mov     %rbx,-0x48(%rax)
> -HIDDEN_FUNC(__savms64_12)
> +MS2SYSV_STUB_BEGIN(savms64_12)
>         mov     %rdi,-0x40(%rax)
>         mov     %rsi,-0x38(%rax)
>         SSE_SAVE
>         ret
> -FUNC_END(__savms64_12)
> -FUNC_END(__savms64_13)
> -FUNC_END(__savms64_14)
> -FUNC_END(__savms64_15)
> -FUNC_END(__savms64_16)
> -FUNC_END(__savms64_17)
> -FUNC_END(__savms64_18)
> +MS2SYSV_STUB_END(savms64_12)
> +MS2SYSV_STUB_END(savms64_13)
> +MS2SYSV_STUB_END(savms64_14)
> +MS2SYSV_STUB_END(savms64_15)
> +MS2SYSV_STUB_END(savms64_16)
> +MS2SYSV_STUB_END(savms64_17)
> +MS2SYSV_STUB_END(savms64_18)
>
>  #endif /* __x86_64__ */
> diff --git a/libgcc/config/i386/savms64f.S b/libgcc/config/i386/savms64f.h
> similarity index 79%
> rename from libgcc/config/i386/savms64f.S
> rename to libgcc/config/i386/savms64f.h
> index 64e91ac0394..723e1080f5c 100644
> --- a/libgcc/config/i386/savms64f.S
> +++ b/libgcc/config/i386/savms64f.h
> @@ -30,26 +30,26 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>   * needed or hard frame pointer used.  */
>
>         .text
> -HIDDEN_FUNC(__savms64f_17)
> +MS2SYSV_STUB_BEGIN(savms64f_17)
>         mov     %r15,-0x68(%rax)
> -HIDDEN_FUNC(__savms64f_16)
> +MS2SYSV_STUB_BEGIN(savms64f_16)
>         mov     %r14,-0x60(%rax)
> -HIDDEN_FUNC(__savms64f_15)
> +MS2SYSV_STUB_BEGIN(savms64f_15)
>         mov     %r13,-0x58(%rax)
> -HIDDEN_FUNC(__savms64f_14)
> +MS2SYSV_STUB_BEGIN(savms64f_14)
>         mov     %r12,-0x50(%rax)
> -HIDDEN_FUNC(__savms64f_13)
> +MS2SYSV_STUB_BEGIN(savms64f_13)
>         mov     %rbx,-0x48(%rax)
> -HIDDEN_FUNC(__savms64f_12)
> +MS2SYSV_STUB_BEGIN(savms64f_12)
>         mov     %rdi,-0x40(%rax)
>         mov     %rsi,-0x38(%rax)
>         SSE_SAVE
>         ret
> -FUNC_END(__savms64f_12)
> -FUNC_END(__savms64f_13)
> -FUNC_END(__savms64f_14)
> -FUNC_END(__savms64f_15)
> -FUNC_END(__savms64f_16)
> -FUNC_END(__savms64f_17)
> +MS2SYSV_STUB_END(savms64f_12)
> +MS2SYSV_STUB_END(savms64f_13)
> +MS2SYSV_STUB_END(savms64f_14)
> +MS2SYSV_STUB_END(savms64f_15)
> +MS2SYSV_STUB_END(savms64f_16)
> +MS2SYSV_STUB_END(savms64f_17)
>
>  #endif /* __x86_64__ */
> diff --git a/libgcc/config/i386/sse_resms64.S b/libgcc/config/i386/sse_resms64.S
> new file mode 100644
> index 00000000000..c87f5cc021d
> --- /dev/null
> +++ b/libgcc/config/i386/sse_resms64.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_SSE
> +#include "resms64.h"
> diff --git a/libgcc/config/i386/sse_resms64f.S b/libgcc/config/i386/sse_resms64f.S
> new file mode 100644
> index 00000000000..3a066bc174a
> --- /dev/null
> +++ b/libgcc/config/i386/sse_resms64f.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_SSE
> +#include "resms64f.h"
> diff --git a/libgcc/config/i386/sse_resms64fx.S b/libgcc/config/i386/sse_resms64fx.S
> new file mode 100644
> index 00000000000..142667a28bf
> --- /dev/null
> +++ b/libgcc/config/i386/sse_resms64fx.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_SSE
> +#include "resms64fx.h"
> diff --git a/libgcc/config/i386/sse_resms64x.S b/libgcc/config/i386/sse_resms64x.S
> new file mode 100644
> index 00000000000..2cfc2b0195f
> --- /dev/null
> +++ b/libgcc/config/i386/sse_resms64x.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_SSE
> +#include "resms64x.h"
> diff --git a/libgcc/config/i386/sse_savms64.S b/libgcc/config/i386/sse_savms64.S
> new file mode 100644
> index 00000000000..52f43075b40
> --- /dev/null
> +++ b/libgcc/config/i386/sse_savms64.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_SSE
> +#include "savms64.h"
> diff --git a/libgcc/config/i386/sse_savms64f.S b/libgcc/config/i386/sse_savms64f.S
> new file mode 100644
> index 00000000000..426be35b53b
> --- /dev/null
> +++ b/libgcc/config/i386/sse_savms64f.S
> @@ -0,0 +1,2 @@
> +#define MS2SYSV_STUB_SSE
> +#include "savms64f.h"
> diff --git a/libgcc/config/i386/t-msabi b/libgcc/config/i386/t-msabi
> index f9806a611aa..ffc9c4f6656 100644
> --- a/libgcc/config/i386/t-msabi
> +++ b/libgcc/config/i386/t-msabi
> @@ -1,7 +1,13 @@
>  # Makefile fragment to support -mcall-ms2sysv-xlogues
> -LIB2ADD_ST += $(srcdir)/config/i386/savms64.S \
> -             $(srcdir)/config/i386/resms64.S \
> -             $(srcdir)/config/i386/resms64x.S \
> -             $(srcdir)/config/i386/savms64f.S \
> -             $(srcdir)/config/i386/resms64f.S \
> -             $(srcdir)/config/i386/resms64fx.S
> +LIB2ADD_ST += $(srcdir)/config/i386/avx_savms64.S \
> +             $(srcdir)/config/i386/avx_resms64.S \
> +             $(srcdir)/config/i386/avx_resms64x.S \
> +             $(srcdir)/config/i386/avx_savms64f.S \
> +             $(srcdir)/config/i386/avx_resms64f.S \
> +             $(srcdir)/config/i386/avx_resms64fx.S \
> +             $(srcdir)/config/i386/sse_savms64.S \
> +             $(srcdir)/config/i386/sse_resms64.S \
> +             $(srcdir)/config/i386/sse_resms64x.S \
> +             $(srcdir)/config/i386/sse_savms64f.S \
> +             $(srcdir)/config/i386/sse_resms64f.S \
> +             $(srcdir)/config/i386/sse_resms64fx.S
> --
> 2.14.1
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-17 15:53 ` Uros Bizjak
@ 2017-09-17 21:56   ` Daniel Santos
  2017-09-19 12:13     ` Rainer Orth
  0 siblings, 1 reply; 20+ messages in thread
From: Daniel Santos @ 2017-09-17 21:56 UTC (permalink / raw)
  To: Uros Bizjak
  Cc: gcc-patches, Jan Hubicka, Ian Lance Taylor, Rainer Orth, Mike Stump

On 09/17/2017 10:53 AM, Uros Bizjak wrote:
> OK.
>
> Thanks,
> Uros.

Thanks. I should have posted this Friday when my tests finished, but
I'll be committing with one minor change so tests don't run on m32 or mx32:

--- a/gcc/testsuite/gcc.target/i386/pr82196-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target lp64 } } */
 /* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
 /* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
 /* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c b/gcc/testsuite/gcc.target/i386/pr82196-2.c
index 31705bee29b..8fe58411d5e 100644
--- a/gcc/testsuite/gcc.target/i386/pr82196-2.c
+++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target lp64 } } */
 /* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
 /* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
 /* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */

Other than that, full regression tests pass.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-17 21:56   ` Daniel Santos
@ 2017-09-19 12:13     ` Rainer Orth
  2017-09-19 13:33       ` Uros Bizjak
  2017-09-19 20:57       ` Daniel Santos
  0 siblings, 2 replies; 20+ messages in thread
From: Rainer Orth @ 2017-09-19 12:13 UTC (permalink / raw)
  To: Daniel Santos
  Cc: Uros Bizjak, gcc-patches, Jan Hubicka, Ian Lance Taylor, Mike Stump

Daniel Santos <daniel.santos@pobox.com> writes:

> On 09/17/2017 10:53 AM, Uros Bizjak wrote:
>> OK.
>>
>> Thanks,
>> Uros.
>
> Thanks. I should have posted this Friday when my tests finished, but
> I'll be committing with one minor change so tests don't run on m32 or mx32:
>
> --- a/gcc/testsuite/gcc.target/i386/pr82196-1.c
> +++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile } */
> +/* { dg-do compile { target lp64 } } */
>  /* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
>  /* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
>  /* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
> diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c
> b/gcc/testsuite/gcc.target/i386/pr82196-2.c
> index 31705bee29b..8fe58411d5e 100644
> --- a/gcc/testsuite/gcc.target/i386/pr82196-2.c
> +++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile } */
> +/* { dg-do compile { target lp64 } } */
>  /* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
>  /* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
>  /* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */
>
> Other than that, full regression tests pass.

However, they do FAIL on 64-bit Solaris/x86:

+FAIL: gcc.target/i386/pr82196-1.c (test for excess errors)

Excess errors:
/vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.target/i386/pr82196-1.c:14:1: error: bp cannot be used in asm here

+UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler call.*__sse_savms64_18
+UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler jmp.*__sse_resms64x_18
+FAIL: gcc.target/i386/pr82196-2.c (test for excess errors)
+UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler call.*__avx_savms64_18
+UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler jmp.*__avx_resms64x_18

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-19 12:13     ` Rainer Orth
@ 2017-09-19 13:33       ` Uros Bizjak
  2017-09-19 13:36         ` Rainer Orth
  2017-09-19 20:57       ` Daniel Santos
  1 sibling, 1 reply; 20+ messages in thread
From: Uros Bizjak @ 2017-09-19 13:33 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Daniel Santos, gcc-patches, Jan Hubicka, Ian Lance Taylor, Mike Stump

On Tue, Sep 19, 2017 at 2:13 PM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> Daniel Santos <daniel.santos@pobox.com> writes:
>
>> On 09/17/2017 10:53 AM, Uros Bizjak wrote:
>>> OK.
>>>
>>> Thanks,
>>> Uros.
>>
>> Thanks. I should have posted this Friday when my tests finished, but
>> I'll be committing with one minor change so tests don't run on m32 or mx32:
>>
>> --- a/gcc/testsuite/gcc.target/i386/pr82196-1.c
>> +++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
>> @@ -1,4 +1,4 @@
>> -/* { dg-do compile } */
>> +/* { dg-do compile { target lp64 } } */
>>  /* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
>>  /* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
>>  /* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
>> diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> b/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> index 31705bee29b..8fe58411d5e 100644
>> --- a/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> +++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> @@ -1,4 +1,4 @@
>> -/* { dg-do compile } */
>> +/* { dg-do compile { target lp64 } } */
>>  /* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
>>  /* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
>>  /* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */
>>
>> Other than that, full regression tests pass.
>
> However, they do FAIL on 64-bit Solaris/x86:
>
> +FAIL: gcc.target/i386/pr82196-1.c (test for excess errors)
>
> Excess errors:
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.target/i386/pr82196-1.c:14:1: error: bp cannot be used in asm here
>
> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler call.*__sse_savms64_18
> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler jmp.*__sse_resms64x_18
> +FAIL: gcc.target/i386/pr82196-2.c (test for excess errors)
> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler call.*__avx_savms64_18
> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler jmp.*__avx_resms64x_18

Does the test compile with -fomit-frame-pointer?

Uros.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-19 13:33       ` Uros Bizjak
@ 2017-09-19 13:36         ` Rainer Orth
  0 siblings, 0 replies; 20+ messages in thread
From: Rainer Orth @ 2017-09-19 13:36 UTC (permalink / raw)
  To: Uros Bizjak
  Cc: Daniel Santos, gcc-patches, Jan Hubicka, Ian Lance Taylor, Mike Stump

Uros Bizjak <ubizjak@gmail.com> writes:

>> However, they do FAIL on 64-bit Solaris/x86:
>>
>> +FAIL: gcc.target/i386/pr82196-1.c (test for excess errors)
>>
>> Excess errors:
>> /vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.target/i386/pr82196-1.c:14:1:
>> error: bp cannot be used in asm here
>>
>> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler call.*__sse_savms64_18
>> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler jmp.*__sse_resms64x_18
>> +FAIL: gcc.target/i386/pr82196-2.c (test for excess errors)
>> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler call.*__avx_savms64_18
>> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler jmp.*__avx_resms64x_18
>
> Does the test compile with -fomit-frame-pointer?

It does indeed, and the patterns are present as expected.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-19 12:13     ` Rainer Orth
  2017-09-19 13:33       ` Uros Bizjak
@ 2017-09-19 20:57       ` Daniel Santos
  1 sibling, 0 replies; 20+ messages in thread
From: Daniel Santos @ 2017-09-19 20:57 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Uros Bizjak, gcc-patches, Jan Hubicka, Ian Lance Taylor, Mike Stump

On 09/19/2017 07:13 AM, Rainer Orth wrote:
> Daniel Santos <daniel.santos@pobox.com> writes:
>
>> On 09/17/2017 10:53 AM, Uros Bizjak wrote:
>>> OK.
>>>
>>> Thanks,
>>> Uros.
>> Thanks. I should have posted this Friday when my tests finished, but
>> I'll be committing with one minor change so tests don't run on m32 or mx32:
>>
>> --- a/gcc/testsuite/gcc.target/i386/pr82196-1.c
>> +++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
>> @@ -1,4 +1,4 @@
>> -/* { dg-do compile } */
>> +/* { dg-do compile { target lp64 } } */
>>  /* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
>>  /* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
>>  /* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
>> diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> b/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> index 31705bee29b..8fe58411d5e 100644
>> --- a/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> +++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> @@ -1,4 +1,4 @@
>> -/* { dg-do compile } */
>> +/* { dg-do compile { target lp64 } } */
>>  /* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
>>  /* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
>>  /* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */
>>
>> Other than that, full regression tests pass.
> However, they do FAIL on 64-bit Solaris/x86:
>
> +FAIL: gcc.target/i386/pr82196-1.c (test for excess errors)
>
> Excess errors:
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.target/i386/pr82196-1.c:14:1: error: bp cannot be used in asm here
>
> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler call.*__sse_savms64_18
> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler jmp.*__sse_resms64x_18
> +FAIL: gcc.target/i386/pr82196-2.c (test for excess errors)
> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler call.*__avx_savms64_18
> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler jmp.*__avx_resms64x_18
>
> 	Rainer

Sorry about that, I forgot about Solaris' default enabled frame
pointers.  I don't even need a test this complicated, I'll make it much
simpler.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-22  8:21               ` Daniel Santos
@ 2017-09-22  8:28                 ` Rainer Orth
  0 siblings, 0 replies; 20+ messages in thread
From: Rainer Orth @ 2017-09-22  8:28 UTC (permalink / raw)
  To: Daniel Santos
  Cc: Jakub Jelinek, Ian Lance Taylor, Dominique d'Humières,
	Uros Bizjak, Iain Sandoe, gcc-patches

Hi Daniel,

> On 09/22/2017 02:18 AM, Rainer Orth wrote:
>> Hi Daniel,
>>
>>> On 09/21/2017 05:18 PM, Daniel Santos wrote:
>>>> So libgcc doesn't use a config.in. :(
>>> Scratch that, I forgot that we're using gcc/config.in via auto-host.h. 
>>> So I only have to add this to gcc/configure.ac and it will be available
>>> for my libgcc header -- this is what I used to sniff out support for the
>>> .hidden directive.
>> Please don't go that route: it's totally the wrong direction.  There's
>> work going on to further decouple libgcc from gcc-private headers and
>> configure results.  libgcc already has its own configure tests for
>> assembler features, and its own config.in.  What's wrong with adapting
>> libitm's avx test in libitm/acinclude.m4 (LIBITM_CHECK_AS_AVX) for
>> libgcc?  Should be trivial...
>>
>> 	Rainer
>>
>
> Oops, I just saw your email after submitting my other patch.  Yes, I am
> mistaken about config.in, sorry about that.  I didn't see a config.h
> file, but examining further it looks like it outputs to auto-target.h. 
> Also, I was looking for some HAVE_AS* macros, but they are named
> differently.

Right: though some are for assembler features, the macros are named
differently.

> I had previously included gcc's auto-host.h since it was in the include
> path in order to use HAVE_AS_HIDDEN, so in order to decouple this I'll

HAVE_GAS_HIDDEN actually ;-)

> need to add that check into libgcc/configure.ac as well.  Again,
> shouldn't be that much code.  Sound sane to you?

You could do that, but it was already used before your patches, so
please separate it from the current issue if you go down that route.
libgcc is still full of cleanup possibilities :-)

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-22  7:43             ` Rainer Orth
@ 2017-09-22  8:21               ` Daniel Santos
  2017-09-22  8:28                 ` Rainer Orth
  0 siblings, 1 reply; 20+ messages in thread
From: Daniel Santos @ 2017-09-22  8:21 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Jakub Jelinek, Ian Lance Taylor, Dominique d'Humières,
	Uros Bizjak, Iain Sandoe, gcc-patches

On 09/22/2017 02:18 AM, Rainer Orth wrote:
> Hi Daniel,
>
>> On 09/21/2017 05:18 PM, Daniel Santos wrote:
>>> So libgcc doesn't use a config.in. :(
>> Scratch that, I forgot that we're using gcc/config.in via auto-host.h. 
>> So I only have to add this to gcc/configure.ac and it will be available
>> for my libgcc header -- this is what I used to sniff out support for the
>> .hidden directive.
> Please don't go that route: it's totally the wrong direction.  There's
> work going on to further decouple libgcc from gcc-private headers and
> configure results.  libgcc already has its own configure tests for
> assembler features, and its own config.in.  What's wrong with adapting
> libitm's avx test in libitm/acinclude.m4 (LIBITM_CHECK_AS_AVX) for
> libgcc?  Should be trivial...
>
> 	Rainer
>

Oops, I just saw your email after submitting my other patch.  Yes, I am
mistaken about config.in, sorry about that.  I didn't see a config.h
file, but examining further it looks like it outputs to auto-target.h. 
Also, I was looking for some HAVE_AS* macros, but they are named
differently.

I had previously included gcc's auto-host.h since it was in the include
path in order to use HAVE_AS_HIDDEN, so in order to decouple this I'll
need to add that check into libgcc/configure.ac as well.  Again,
shouldn't be that much code.  Sound sane to you?

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-22  2:42           ` Daniel Santos
@ 2017-09-22  7:43             ` Rainer Orth
  2017-09-22  8:21               ` Daniel Santos
  0 siblings, 1 reply; 20+ messages in thread
From: Rainer Orth @ 2017-09-22  7:43 UTC (permalink / raw)
  To: Daniel Santos
  Cc: Jakub Jelinek, Ian Lance Taylor, Dominique d'Humières,
	Uros Bizjak, Iain Sandoe, gcc-patches

Hi Daniel,

> On 09/21/2017 05:18 PM, Daniel Santos wrote:
>> So libgcc doesn't use a config.in. :(
>
> Scratch that, I forgot that we're using gcc/config.in via auto-host.h. 
> So I only have to add this to gcc/configure.ac and it will be available
> for my libgcc header -- this is what I used to sniff out support for the
> .hidden directive.

Please don't go that route: it's totally the wrong direction.  There's
work going on to further decouple libgcc from gcc-private headers and
configure results.  libgcc already has its own configure tests for
assembler features, and its own config.in.  What's wrong with adapting
libitm's avx test in libitm/acinclude.m4 (LIBITM_CHECK_AS_AVX) for
libgcc?  Should be trivial...

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-21 22:12         ` Daniel Santos
@ 2017-09-22  2:42           ` Daniel Santos
  2017-09-22  7:43             ` Rainer Orth
  0 siblings, 1 reply; 20+ messages in thread
From: Daniel Santos @ 2017-09-22  2:42 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Jakub Jelinek, Ian Lance Taylor, Dominique d'Humières,
	Uros Bizjak, Iain Sandoe, gcc-patches

On 09/21/2017 05:18 PM, Daniel Santos wrote:
> So libgcc doesn't use a config.in. :(

Scratch that, I forgot that we're using gcc/config.in via auto-host.h. 
So I only have to add this to gcc/configure.ac and it will be available
for my libgcc header -- this is what I used to sniff out support for the
.hidden directive.

I still wouldn't mind centralizing assembler sniffing in config/as.m4
(or similar) later on.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-21 16:14       ` Rainer Orth
@ 2017-09-21 22:12         ` Daniel Santos
  2017-09-22  2:42           ` Daniel Santos
  0 siblings, 1 reply; 20+ messages in thread
From: Daniel Santos @ 2017-09-21 22:12 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Jakub Jelinek, Ian Lance Taylor, Dominique d'Humières,
	Uros Bizjak, Iain Sandoe, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2534 bytes --]

On 09/21/2017 11:14 AM, Rainer Orth wrote:
> Hi Daniel,
>
>> On 09/19/2017 01:58 AM, Jakub Jelinek wrote:
>>> What can be done in libgcc is detect in configure whether the assembler
>>> supports AVX, and if not, provide some alternative (e.g. because the insns
>>> are always the same, you could just code them as .byte or something similar).
>>>
>>> Say like:
>>> --- i386-asm.h	2017-09-18 18:34:30.917126996 +0200
>>> +++ i386-asm.h	2017-09-19 08:56:58.829559038 +0200
>>> @@ -70,6 +70,7 @@ ASMNAME(fn):
>>>  #ifdef MS2SYSV_STUB_AVX
>>>  # define MS2SYSV_STUB_PREFIX __avx_
>>>  # define MOVAPS vmovaps
>>> +# define BYTE .byte
>>>  #elif defined(MS2SYSV_STUB_SSE)
>>>  # define MS2SYSV_STUB_PREFIX __sse_
>>>  # define MOVAPS movaps
>>> @@ -84,7 +85,8 @@ ASMNAME(fn):
>>>  	FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
>>>  
>>>  /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
>>> -# define SSE_SAVE		   \
>>> +# ifdef HAVE_AS_AVX
>> I'm not exactly an autotools expert, but libtim defines HAVE_AS_AVX from
>> libitm/acinclude.m4 -- of course I need it in libgcc.  Similarly, gcc
>> has a nice generic gcc_GAS_CHECK_FEATURE macro in gcc/acinclude.m4 which
>> it uses for all of its HAVE_AS_* macro tests defined in
>> gcc/configure.ac.  I can just copy, paste and edit what's in libitm, but
>> I find that rather distasteful.  Is there a cleaner way to do this?  Can
>> I suck gcc_GAS_CHECK_FEATURE and it's deps out of gcc/acinclude.m4 and
>> put it somewhere central, like config/as.m4?  The upside would be the
>> ability to make HAVE_AS_* macros in other sub-projects more uniform.
> This might be an option as a followup: less code duplication is
> certainly a good thing ;-)
>
>> Alternatively, I can just do the copy and paste and deal with it -- it's
>> not that much code. :)
> However, given that the above will take some time and testing and your
> patch has broken macOS bootstrap, I'd go this route now to unbreak the
> tree ASAP.
>
> 	Rainer

A very good point!  So libgcc doesn't use a config.in. :(  So what about
committing my patch as is with HAVE_AS_AVX never defined and the avx
version of the stubs always being built via the .byte directives so that
the build is un-broken, and then figure out how (and where) to add
HAVE_AS_AVX afterwards?  I would still prefer to run a full bootstrap,
but updating an already build bootstrap is good and the tests should
hopefully be fixed on Solaris as well.

Thanks,
Daniel



[-- Attachment #2: pr82196-fixup.diff --]
[-- Type: text/x-patch, Size: 5237 bytes --]

diff --git a/gcc/testsuite/gcc.target/i386/pr82196-1.c b/gcc/testsuite/gcc.target/i386/pr82196-1.c
index ef858328f00..541d975480d 100644
--- a/gcc/testsuite/gcc.target/i386/pr82196-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
@@ -1,7 +1,7 @@
 /* { dg-do compile { target lp64 } } */
 /* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
-/* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
-/* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
+/* { dg-final { scan-assembler "call.*__sse_savms64f?_12" } } */
+/* { dg-final { scan-assembler "jmp.*__sse_resms64f?x_12" } } */
 
 void __attribute__((sysv_abi)) a() {
 }
@@ -9,6 +9,5 @@ void __attribute__((sysv_abi)) a() {
 static void __attribute__((sysv_abi)) (*volatile a_noinfo)() = a;
 
 void __attribute__((ms_abi)) b() {
-  __asm__ __volatile__ ("" :::"rbx", "rbp", "r12", "r13", "r14", "r15");
   a_noinfo ();
 }
diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c b/gcc/testsuite/gcc.target/i386/pr82196-2.c
index 8fe58411d5e..7166d068bc1 100644
--- a/gcc/testsuite/gcc.target/i386/pr82196-2.c
+++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
@@ -1,7 +1,7 @@
 /* { dg-do compile { target lp64 } } */
 /* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
-/* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
-/* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */
+/* { dg-final { scan-assembler "call.*__avx_savms64f?_12" } } */
+/* { dg-final { scan-assembler "jmp.*__avx_resms64f?x_12" } } */
 
 void __attribute__((sysv_abi)) a() {
 }
@@ -9,6 +9,5 @@ void __attribute__((sysv_abi)) a() {
 static void __attribute__((sysv_abi)) (*volatile a_noinfo)() = a;
 
 void __attribute__((ms_abi)) b() {
-  __asm__ __volatile__ ("" :::"rbx", "rbp", "r12", "r13", "r14", "r15");
   a_noinfo ();
 }
diff --git a/libgcc/config/i386/i386-asm.h b/libgcc/config/i386/i386-asm.h
index 424e0f72aac..91e1c0123ff 100644
--- a/libgcc/config/i386/i386-asm.h
+++ b/libgcc/config/i386/i386-asm.h
@@ -69,13 +69,15 @@ ASMNAME(fn):
 
 #ifdef MS2SYSV_STUB_AVX
 # define MS2SYSV_STUB_PREFIX __avx_
-# define MOVAPS vmovaps
+# ifdef HAVE_AS_AVX
+#  define MOVAPS vmovaps
+# endif
 #elif defined(MS2SYSV_STUB_SSE)
 # define MS2SYSV_STUB_PREFIX __sse_
 # define MOVAPS movaps
 #endif
 
-#if defined (MS2SYSV_STUB_PREFIX) && defined (MOVAPS)
+#if defined (MS2SYSV_STUB_PREFIX)
 
 # define MS2SYSV_STUB_BEGIN(base_name) \
 	HIDDEN_FUNC(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
@@ -83,8 +85,10 @@ ASMNAME(fn):
 # define MS2SYSV_STUB_END(base_name) \
 	FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
 
-/* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
-# define SSE_SAVE		   \
+/* If expanding for sse or avx and we have assembler support.  */
+# ifdef MOVAPS
+/* Save SSE registers 6-15 using rax as the base address.  */
+#  define SSE_SAVE		   \
 	MOVAPS %xmm15,-0x30(%rax); \
 	MOVAPS %xmm14,-0x20(%rax); \
 	MOVAPS %xmm13,-0x10(%rax); \
@@ -96,8 +100,8 @@ ASMNAME(fn):
 	MOVAPS %xmm7,  0x50(%rax); \
 	MOVAPS %xmm6,  0x60(%rax)
 
-/* Restore SSE registers 6-15. off is the offset of rsi to get to xmm6.  */
-# define SSE_RESTORE		    \
+/* Restore SSE registers 6-15 using rsi as the base address.  */
+#  define SSE_RESTORE		    \
 	MOVAPS -0x30(%rsi), %xmm15; \
 	MOVAPS -0x20(%rsi), %xmm14; \
 	MOVAPS -0x10(%rsi), %xmm13; \
@@ -108,6 +112,32 @@ ASMNAME(fn):
 	MOVAPS  0x40(%rsi), %xmm8 ; \
 	MOVAPS  0x50(%rsi), %xmm7 ; \
 	MOVAPS  0x60(%rsi), %xmm6
-
+# else /* MOVAPS */
+/* If the assembler doesn't support AVX then directly emit machine code
+   for the instructions above directly.  */
+#  define BYTE .byte
+#  define SSE_SAVE							    \
+	BYTE 0xc5, 0x78, 0x29, 0x78, 0xd0; /* vmovaps %xmm15,-0x30(%rax) */ \
+	BYTE 0xc5, 0x78, 0x29, 0x70, 0xe0; /* vmovaps %xmm14,-0x20(%rax) */ \
+	BYTE 0xc5, 0x78, 0x29, 0x68, 0xf0; /* vmovaps %xmm13,-0x10(%rax) */ \
+	BYTE 0xc5, 0x78, 0x29, 0x20;       /* vmovaps %xmm12,     (%rax) */ \
+	BYTE 0xc5, 0x78, 0x29, 0x58, 0x10; /* vmovaps %xmm11, 0x10(%rax) */ \
+	BYTE 0xc5, 0x78, 0x29, 0x50, 0x20; /* vmovaps %xmm10, 0x20(%rax) */ \
+	BYTE 0xc5, 0x78, 0x29, 0x48, 0x30; /* vmovaps %xmm9,  0x30(%rax) */ \
+	BYTE 0xc5, 0x78, 0x29, 0x40, 0x40; /* vmovaps %xmm8,  0x40(%rax) */ \
+	BYTE 0xc5, 0xf8, 0x29, 0x78, 0x50; /* vmovaps %xmm7,  0x50(%rax) */ \
+	BYTE 0xc5, 0xf8, 0x29, 0x70, 0x60; /* vmovaps %xmm6,  0x60(%rax) */
+#  define SSE_RESTORE							    \
+	BYTE 0xc5, 0x78, 0x28, 0x7e, 0xd0; /* vmovaps -0x30(%rsi),%xmm15 */ \
+	BYTE 0xc5, 0x78, 0x28, 0x76, 0xe0; /* vmovaps -0x20(%rsi),%xmm14 */ \
+	BYTE 0xc5, 0x78, 0x28, 0x6e, 0xf0; /* vmovaps -0x10(%rsi),%xmm13 */ \
+	BYTE 0xc5, 0x78, 0x28, 0x26;       /* vmovaps      (%rsi),%xmm12 */ \
+	BYTE 0xc5, 0x78, 0x28, 0x5e, 0x10; /* vmovaps  0x10(%rsi),%xmm11 */ \
+	BYTE 0xc5, 0x78, 0x28, 0x56, 0x20; /* vmovaps  0x20(%rsi),%xmm10 */ \
+	BYTE 0xc5, 0x78, 0x28, 0x4e, 0x30; /* vmovaps  0x30(%rsi),%xmm9  */ \
+	BYTE 0xc5, 0x78, 0x28, 0x46, 0x40; /* vmovaps  0x40(%rsi),%xmm8  */ \
+	BYTE 0xc5, 0xf8, 0x28, 0x7e, 0x50; /* vmovaps  0x50(%rsi),%xmm7  */ \
+	BYTE 0xc5, 0xf8, 0x28, 0x76, 0x60; /* vmovaps  0x60(%rsi),%xmm6  */
+# endif /* MOVAPS */
 #endif /* defined (MS2SYSV_STUB_ISA) && defined (MOVAPS) */
 #endif /* I386_ASM_H */

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-21  1:52     ` Daniel Santos
  2017-09-21  6:20       ` Uros Bizjak
@ 2017-09-21 16:14       ` Rainer Orth
  2017-09-21 22:12         ` Daniel Santos
  1 sibling, 1 reply; 20+ messages in thread
From: Rainer Orth @ 2017-09-21 16:14 UTC (permalink / raw)
  To: Daniel Santos
  Cc: Jakub Jelinek, Ian Lance Taylor, Dominique d'Humières,
	Uros Bizjak, Iain Sandoe, gcc-patches

Hi Daniel,

> On 09/19/2017 01:58 AM, Jakub Jelinek wrote:
>> What can be done in libgcc is detect in configure whether the assembler
>> supports AVX, and if not, provide some alternative (e.g. because the insns
>> are always the same, you could just code them as .byte or something similar).
>>
>> Say like:
>> --- i386-asm.h	2017-09-18 18:34:30.917126996 +0200
>> +++ i386-asm.h	2017-09-19 08:56:58.829559038 +0200
>> @@ -70,6 +70,7 @@ ASMNAME(fn):
>>  #ifdef MS2SYSV_STUB_AVX
>>  # define MS2SYSV_STUB_PREFIX __avx_
>>  # define MOVAPS vmovaps
>> +# define BYTE .byte
>>  #elif defined(MS2SYSV_STUB_SSE)
>>  # define MS2SYSV_STUB_PREFIX __sse_
>>  # define MOVAPS movaps
>> @@ -84,7 +85,8 @@ ASMNAME(fn):
>>  	FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
>>  
>>  /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
>> -# define SSE_SAVE		   \
>> +# ifdef HAVE_AS_AVX
>
> I'm not exactly an autotools expert, but libtim defines HAVE_AS_AVX from
> libitm/acinclude.m4 -- of course I need it in libgcc.  Similarly, gcc
> has a nice generic gcc_GAS_CHECK_FEATURE macro in gcc/acinclude.m4 which
> it uses for all of its HAVE_AS_* macro tests defined in
> gcc/configure.ac.  I can just copy, paste and edit what's in libitm, but
> I find that rather distasteful.  Is there a cleaner way to do this?  Can
> I suck gcc_GAS_CHECK_FEATURE and it's deps out of gcc/acinclude.m4 and
> put it somewhere central, like config/as.m4?  The upside would be the
> ability to make HAVE_AS_* macros in other sub-projects more uniform.

This might be an option as a followup: less code duplication is
certainly a good thing ;-)

> Alternatively, I can just do the copy and paste and deal with it -- it's
> not that much code. :)

However, given that the above will take some time and testing and your
patch has broken macOS bootstrap, I'd go this route now to unbreak the
tree ASAP.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-21  1:52     ` Daniel Santos
@ 2017-09-21  6:20       ` Uros Bizjak
  2017-09-21 16:14       ` Rainer Orth
  1 sibling, 0 replies; 20+ messages in thread
From: Uros Bizjak @ 2017-09-21  6:20 UTC (permalink / raw)
  To: Daniel Santos
  Cc: Jakub Jelinek, Ian Lance Taylor, Dominique d'Humières,
	Iain Sandoe, gcc-patches

On Thu, Sep 21, 2017 at 3:58 AM, Daniel Santos <daniel.santos@pobox.com> wrote:
> On 09/19/2017 01:58 AM, Jakub Jelinek wrote:
>> What can be done in libgcc is detect in configure whether the assembler
>> supports AVX, and if not, provide some alternative (e.g. because the insns
>> are always the same, you could just code them as .byte or something similar).
>>
>> Say like:
>> --- i386-asm.h        2017-09-18 18:34:30.917126996 +0200
>> +++ i386-asm.h        2017-09-19 08:56:58.829559038 +0200
>> @@ -70,6 +70,7 @@ ASMNAME(fn):
>>  #ifdef MS2SYSV_STUB_AVX
>>  # define MS2SYSV_STUB_PREFIX __avx_
>>  # define MOVAPS vmovaps
>> +# define BYTE .byte
>>  #elif defined(MS2SYSV_STUB_SSE)
>>  # define MS2SYSV_STUB_PREFIX __sse_
>>  # define MOVAPS movaps
>> @@ -84,7 +85,8 @@ ASMNAME(fn):
>>       FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
>>
>>  /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
>> -# define SSE_SAVE               \
>> +# ifdef HAVE_AS_AVX
>
> I'm not exactly an autotools expert, but libtim defines HAVE_AS_AVX from
> libitm/acinclude.m4 -- of course I need it in libgcc.  Similarly, gcc
> has a nice generic gcc_GAS_CHECK_FEATURE macro in gcc/acinclude.m4 which
> it uses for all of its HAVE_AS_* macro tests defined in
> gcc/configure.ac.  I can just copy, paste and edit what's in libitm, but
> I find that rather distasteful.  Is there a cleaner way to do this?  Can
> I suck gcc_GAS_CHECK_FEATURE and it's deps out of gcc/acinclude.m4 and
> put it somewhere central, like config/as.m4?  The upside would be the
> ability to make HAVE_AS_* macros in other sub-projects more uniform.
>
> Alternatively, I can just do the copy and paste and deal with it -- it's
> not that much code. :)
>
> Also, is there any sense in doing this same check for SSE support in the
> assembler?  It's been out for 18 years now.

binutils 2.13.1 are required to buld the compiler on i?86-*-linux*, so
I guess SSE support is assumed.

Uros.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-19  6:58   ` Jakub Jelinek
  2017-09-19 20:07     ` Daniel Santos
@ 2017-09-21  1:52     ` Daniel Santos
  2017-09-21  6:20       ` Uros Bizjak
  2017-09-21 16:14       ` Rainer Orth
  1 sibling, 2 replies; 20+ messages in thread
From: Daniel Santos @ 2017-09-21  1:52 UTC (permalink / raw)
  To: Jakub Jelinek, Ian Lance Taylor
  Cc: Dominique d'Humières, Uros Bizjak, Iain Sandoe,
	gcc-patches, Uros Bizjak

On 09/19/2017 01:58 AM, Jakub Jelinek wrote:
> What can be done in libgcc is detect in configure whether the assembler
> supports AVX, and if not, provide some alternative (e.g. because the insns
> are always the same, you could just code them as .byte or something similar).
>
> Say like:
> --- i386-asm.h	2017-09-18 18:34:30.917126996 +0200
> +++ i386-asm.h	2017-09-19 08:56:58.829559038 +0200
> @@ -70,6 +70,7 @@ ASMNAME(fn):
>  #ifdef MS2SYSV_STUB_AVX
>  # define MS2SYSV_STUB_PREFIX __avx_
>  # define MOVAPS vmovaps
> +# define BYTE .byte
>  #elif defined(MS2SYSV_STUB_SSE)
>  # define MS2SYSV_STUB_PREFIX __sse_
>  # define MOVAPS movaps
> @@ -84,7 +85,8 @@ ASMNAME(fn):
>  	FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
>  
>  /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
> -# define SSE_SAVE		   \
> +# ifdef HAVE_AS_AVX

I'm not exactly an autotools expert, but libtim defines HAVE_AS_AVX from
libitm/acinclude.m4 -- of course I need it in libgcc.  Similarly, gcc
has a nice generic gcc_GAS_CHECK_FEATURE macro in gcc/acinclude.m4 which
it uses for all of its HAVE_AS_* macro tests defined in
gcc/configure.ac.  I can just copy, paste and edit what's in libitm, but
I find that rather distasteful.  Is there a cleaner way to do this?  Can
I suck gcc_GAS_CHECK_FEATURE and it's deps out of gcc/acinclude.m4 and
put it somewhere central, like config/as.m4?  The upside would be the
ability to make HAVE_AS_* macros in other sub-projects more uniform.

Alternatively, I can just do the copy and paste and deal with it -- it's
not that much code. :)

Also, is there any sense in doing this same check for SSE support in the
assembler?  It's been out for 18 years now.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-19  6:58   ` Jakub Jelinek
@ 2017-09-19 20:07     ` Daniel Santos
  2017-09-21  1:52     ` Daniel Santos
  1 sibling, 0 replies; 20+ messages in thread
From: Daniel Santos @ 2017-09-19 20:07 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Dominique d'Humières, Mike Stump, Uros Bizjak,
	Iain Sandoe, gcc-patches

On 09/19/2017 01:58 AM, Jakub Jelinek wrote:
> On Mon, Sep 18, 2017 at 06:10:29PM -0500, Daniel Santos wrote:
>> Mike, can you take a look at this please?
>>
>> On 09/18/2017 10:17 AM, Dominique d'Humières wrote:
>>> This patch (r252896) breaks bootstrap on x86_64-apple-darwin10 configured with
>>>
>>> ../work/configure --prefix=/opt/gcc/gcc8w --enable-languages=c,c++,fortran,objc,obj-c++,ada,lto --with-gmp=/opt/mp-new --with-system-zlib --with-isl=/opt/mp-new --enable-lto --enable-plugin
>>>
>>> /opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/bin/ -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/lib/ -isystem /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/include -isystem /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/sys-include    -g -O2 -O2  -g -O2 -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe -fno-common -I. -I. -I../.././gcc -I../../../work/libgcc -I../../../work/libgcc/. -I../../../work/libgcc/../gcc -I../../../work/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -o avx_savms64_s.o -MT avx_savms64_s.o -MD -MP -MF avx_savms64_s.dep -DSHARED -c -xassembler-with-cpp ../../../work/libgcc/config/i386/avx_savms64.S
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm15,-0x30(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm14,-0x20(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm13,-0x10(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm12, (%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm11, 0x10(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm10, 0x20(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm9, 0x30(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm8, 0x40(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm7, 0x50(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm6, 0x60(%rax)'
>>> make[3]: *** [avx_savms64_s.o] Error 1
>>>
>>> Dominique
>> Thanks for the report.  AVX has been out since early 2011 and Wikipedia
>> claims that AVX support was added to OSX in version 10.6.8 in June 2011
>> and you seem to be using 10.8.0.  I would presume that also means that
>> the assembler supports it.  So I'm going to guess that it's the
>> "-mmacosx-version-min=10.5" parameter.  Can you please try setting that
>> to 10.6.8 and let me know the result?  I don't know what the minimum
>> system requirements for GCC 8 are going to be, but if it includes these
>> older versions of OSX then I'll have to figure out how to cope with it
>> in the libgcc build.
> What can be done in libgcc is detect in configure whether the assembler
> supports AVX, and if not, provide some alternative (e.g. because the insns
> are always the same, you could just code them as .byte or something similar).
>
> Say like:
> --- i386-asm.h	2017-09-18 18:34:30.917126996 +0200
> +++ i386-asm.h	2017-09-19 08:56:58.829559038 +0200
> @@ -70,6 +70,7 @@ ASMNAME(fn):
>  #ifdef MS2SYSV_STUB_AVX
>  # define MS2SYSV_STUB_PREFIX __avx_
>  # define MOVAPS vmovaps
> +# define BYTE .byte
>  #elif defined(MS2SYSV_STUB_SSE)
>  # define MS2SYSV_STUB_PREFIX __sse_
>  # define MOVAPS movaps
> @@ -84,7 +85,8 @@ ASMNAME(fn):
>  	FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
>  
>  /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
> -# define SSE_SAVE		   \
> +# ifdef HAVE_AS_AVX
> +#  define SSE_SAVE		   \
>  	MOVAPS %xmm15,-0x30(%rax); \
>  	MOVAPS %xmm14,-0x20(%rax); \
>  	MOVAPS %xmm13,-0x10(%rax); \
> @@ -95,6 +97,21 @@ ASMNAME(fn):
>  	MOVAPS %xmm8,  0x40(%rax); \
>  	MOVAPS %xmm7,  0x50(%rax); \
>  	MOVAPS %xmm6,  0x60(%rax)
> +# else
> +/* If the assembler doesn't have AVX support, emit machine code for
> +   the above directly.  */
> +#  define SSE_SAVE		   \
> +	BYTE 0x44, 0x0f, 0x29, 0x78, 0xd0; \
> +	BYTE 0x44, 0x0f, 0x29, 0x70, 0xe0; \
> +	BYTE 0x44, 0x0f, 0x29, 0x68, 0xf0; \
> +	BYTE 0x44, 0x0f, 0x29, 0x20;	   \
> +	BYTE 0x44, 0x0f, 0x29, 0x58, 0x10; \
> +	BYTE 0x44, 0x0f, 0x29, 0x50, 0x20; \
> +	BYTE 0x44, 0x0f, 0x29, 0x48, 0x30; \
> +	BYTE 0x44, 0x0f, 0x29, 0x40, 0x40; \
> +	BYTE 0x0f, 0x29, 0x78, 0x50;	   \
> +	BYTE 0x0f, 0x29, 0x70, 0x60
> +# endif
>  
>  /* Restore SSE registers 6-15. off is the offset of rsi to get to xmm6.  */
>  # define SSE_RESTORE		    \
>
>
> 	Jakub

Wow, thanks for that Jakub!  I was thinking to just omit the support if
the bootstrapping assembler doesn't support it, presuming that it would
be the same assembler used to actually compile programs later.  This
might be a bad assumption, so this sounds like a better idea since the
offsets are always the same.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-18 23:04 ` Daniel Santos
  2017-09-19  6:10   ` Uros Bizjak
@ 2017-09-19  6:58   ` Jakub Jelinek
  2017-09-19 20:07     ` Daniel Santos
  2017-09-21  1:52     ` Daniel Santos
  1 sibling, 2 replies; 20+ messages in thread
From: Jakub Jelinek @ 2017-09-19  6:58 UTC (permalink / raw)
  To: Daniel Santos
  Cc: Dominique d'Humières, Mike Stump, Uros Bizjak,
	Iain Sandoe, gcc-patches

On Mon, Sep 18, 2017 at 06:10:29PM -0500, Daniel Santos wrote:
> Mike, can you take a look at this please?
> 
> On 09/18/2017 10:17 AM, Dominique d'Humières wrote:
> > This patch (r252896) breaks bootstrap on x86_64-apple-darwin10 configured with
> >
> > ../work/configure --prefix=/opt/gcc/gcc8w --enable-languages=c,c++,fortran,objc,obj-c++,ada,lto --with-gmp=/opt/mp-new --with-system-zlib --with-isl=/opt/mp-new --enable-lto --enable-plugin
> >
> > /opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/bin/ -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/lib/ -isystem /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/include -isystem /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/sys-include    -g -O2 -O2  -g -O2 -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe -fno-common -I. -I. -I../.././gcc -I../../../work/libgcc -I../../../work/libgcc/. -I../../../work/libgcc/../gcc -I../../../work/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -o avx_savms64_s.o -MT avx_savms64_s.o -MD -MP -MF avx_savms64_s.dep -DSHARED -c -xassembler-with-cpp ../../../work/libgcc/config/i386/avx_savms64.S
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm15,-0x30(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm14,-0x20(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm13,-0x10(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm12, (%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm11, 0x10(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm10, 0x20(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm9, 0x30(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm8, 0x40(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm7, 0x50(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm6, 0x60(%rax)'
> > make[3]: *** [avx_savms64_s.o] Error 1
> >
> > Dominique
> 
> Thanks for the report.  AVX has been out since early 2011 and Wikipedia
> claims that AVX support was added to OSX in version 10.6.8 in June 2011
> and you seem to be using 10.8.0.  I would presume that also means that
> the assembler supports it.  So I'm going to guess that it's the
> "-mmacosx-version-min=10.5" parameter.  Can you please try setting that
> to 10.6.8 and let me know the result?  I don't know what the minimum
> system requirements for GCC 8 are going to be, but if it includes these
> older versions of OSX then I'll have to figure out how to cope with it
> in the libgcc build.

What can be done in libgcc is detect in configure whether the assembler
supports AVX, and if not, provide some alternative (e.g. because the insns
are always the same, you could just code them as .byte or something similar).

Say like:
--- i386-asm.h	2017-09-18 18:34:30.917126996 +0200
+++ i386-asm.h	2017-09-19 08:56:58.829559038 +0200
@@ -70,6 +70,7 @@ ASMNAME(fn):
 #ifdef MS2SYSV_STUB_AVX
 # define MS2SYSV_STUB_PREFIX __avx_
 # define MOVAPS vmovaps
+# define BYTE .byte
 #elif defined(MS2SYSV_STUB_SSE)
 # define MS2SYSV_STUB_PREFIX __sse_
 # define MOVAPS movaps
@@ -84,7 +85,8 @@ ASMNAME(fn):
 	FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
 
 /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
-# define SSE_SAVE		   \
+# ifdef HAVE_AS_AVX
+#  define SSE_SAVE		   \
 	MOVAPS %xmm15,-0x30(%rax); \
 	MOVAPS %xmm14,-0x20(%rax); \
 	MOVAPS %xmm13,-0x10(%rax); \
@@ -95,6 +97,21 @@ ASMNAME(fn):
 	MOVAPS %xmm8,  0x40(%rax); \
 	MOVAPS %xmm7,  0x50(%rax); \
 	MOVAPS %xmm6,  0x60(%rax)
+# else
+/* If the assembler doesn't have AVX support, emit machine code for
+   the above directly.  */
+#  define SSE_SAVE		   \
+	BYTE 0x44, 0x0f, 0x29, 0x78, 0xd0; \
+	BYTE 0x44, 0x0f, 0x29, 0x70, 0xe0; \
+	BYTE 0x44, 0x0f, 0x29, 0x68, 0xf0; \
+	BYTE 0x44, 0x0f, 0x29, 0x20;	   \
+	BYTE 0x44, 0x0f, 0x29, 0x58, 0x10; \
+	BYTE 0x44, 0x0f, 0x29, 0x50, 0x20; \
+	BYTE 0x44, 0x0f, 0x29, 0x48, 0x30; \
+	BYTE 0x44, 0x0f, 0x29, 0x40, 0x40; \
+	BYTE 0x0f, 0x29, 0x78, 0x50;	   \
+	BYTE 0x0f, 0x29, 0x70, 0x60
+# endif
 
 /* Restore SSE registers 6-15. off is the offset of rsi to get to xmm6.  */
 # define SSE_RESTORE		    \


	Jakub

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-18 23:04 ` Daniel Santos
@ 2017-09-19  6:10   ` Uros Bizjak
  2017-09-19  6:58   ` Jakub Jelinek
  1 sibling, 0 replies; 20+ messages in thread
From: Uros Bizjak @ 2017-09-19  6:10 UTC (permalink / raw)
  To: Daniel Santos
  Cc: Dominique d'Humières, Mike Stump, Iain Sandoe, gcc-patches

On Tue, Sep 19, 2017 at 1:10 AM, Daniel Santos <daniel.santos@pobox.com> wrote:
> Mike, can you take a look at this please?
>
> On 09/18/2017 10:17 AM, Dominique d'Humières wrote:
>> This patch (r252896) breaks bootstrap on x86_64-apple-darwin10 configured with
>>
>> ../work/configure --prefix=/opt/gcc/gcc8w --enable-languages=c,c++,fortran,objc,obj-c++,ada,lto --with-gmp=/opt/mp-new --with-system-zlib --with-isl=/opt/mp-new --enable-lto --enable-plugin
>>
>> /opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/bin/ -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/lib/ -isystem /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/include -isystem /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/sys-include    -g -O2 -O2  -g -O2 -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe -fno-common -I. -I. -I../.././gcc -I../../../work/libgcc -I../../../work/libgcc/. -I../../../work/libgcc/../gcc -I../../../work/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -o avx_savms64_s.o -MT avx_savms64_s.o -MD -MP -MF avx_savms64_s.dep -DSHARED -c -xassembler-with-cpp ../../../work/libgcc/config/i386/avx_savms64.S
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm15,-0x30(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm14,-0x20(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm13,-0x10(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm12, (%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm11, 0x10(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm10, 0x20(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm9, 0x30(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm8, 0x40(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm7, 0x50(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm6, 0x60(%rax)'
>> make[3]: *** [avx_savms64_s.o] Error 1
>>
>> Dominique
>
> Thanks for the report.  AVX has been out since early 2011 and Wikipedia
> claims that AVX support was added to OSX in version 10.6.8 in June 2011
> and you seem to be using 10.8.0.  I would presume that also means that
> the assembler supports it.  So I'm going to guess that it's the
> "-mmacosx-version-min=10.5" parameter.  Can you please try setting that
> to 10.6.8 and let me know the result?  I don't know what the minimum
> system requirements for GCC 8 are going to be, but if it includes these
> older versions of OSX then I'll have to figure out how to cope with it
> in the libgcc build.

Please look at how libitm handles this issue.

Uros.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
  2017-09-18 15:17 Dominique d'Humières
@ 2017-09-18 23:04 ` Daniel Santos
  2017-09-19  6:10   ` Uros Bizjak
  2017-09-19  6:58   ` Jakub Jelinek
  0 siblings, 2 replies; 20+ messages in thread
From: Daniel Santos @ 2017-09-18 23:04 UTC (permalink / raw)
  To: Dominique d'Humières, Mike Stump
  Cc: Uros Bizjak, Iain Sandoe, gcc-patches

Mike, can you take a look at this please?

On 09/18/2017 10:17 AM, Dominique d'Humières wrote:
> This patch (r252896) breaks bootstrap on x86_64-apple-darwin10 configured with
>
> ../work/configure --prefix=/opt/gcc/gcc8w --enable-languages=c,c++,fortran,objc,obj-c++,ada,lto --with-gmp=/opt/mp-new --with-system-zlib --with-isl=/opt/mp-new --enable-lto --enable-plugin
>
> /opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/bin/ -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/lib/ -isystem /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/include -isystem /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/sys-include    -g -O2 -O2  -g -O2 -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe -fno-common -I. -I. -I../.././gcc -I../../../work/libgcc -I../../../work/libgcc/. -I../../../work/libgcc/../gcc -I../../../work/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -o avx_savms64_s.o -MT avx_savms64_s.o -MD -MP -MF avx_savms64_s.dep -DSHARED -c -xassembler-with-cpp ../../../work/libgcc/config/i386/avx_savms64.S
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm15,-0x30(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm14,-0x20(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm13,-0x10(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm12, (%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm11, 0x10(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm10, 0x20(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm9, 0x30(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm8, 0x40(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm7, 0x50(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm6, 0x60(%rax)'
> make[3]: *** [avx_savms64_s.o] Error 1
>
> Dominique

Thanks for the report.  AVX has been out since early 2011 and Wikipedia
claims that AVX support was added to OSX in version 10.6.8 in June 2011
and you seem to be using 10.8.0.  I would presume that also means that
the assembler supports it.  So I'm going to guess that it's the
"-mmacosx-version-min=10.5" parameter.  Can you please try setting that
to 10.6.8 and let me know the result?  I don't know what the minimum
system requirements for GCC 8 are going to be, but if it includes these
older versions of OSX then I'll have to figure out how to cope with it
in the libgcc build.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV
@ 2017-09-18 15:17 Dominique d'Humières
  2017-09-18 23:04 ` Daniel Santos
  0 siblings, 1 reply; 20+ messages in thread
From: Dominique d'Humières @ 2017-09-18 15:17 UTC (permalink / raw)
  To: Daniel Santos; +Cc: Uros Bizjak, Iain Sandoe, gcc-patches

This patch (r252896) breaks bootstrap on x86_64-apple-darwin10 configured with

../work/configure --prefix=/opt/gcc/gcc8w --enable-languages=c,c++,fortran,objc,obj-c++,ada,lto --with-gmp=/opt/mp-new --with-system-zlib --with-isl=/opt/mp-new --enable-lto --enable-plugin

/opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/bin/ -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/lib/ -isystem /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/include -isystem /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/sys-include    -g -O2 -O2  -g -O2 -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe -fno-common -I. -I. -I../.././gcc -I../../../work/libgcc -I../../../work/libgcc/. -I../../../work/libgcc/../gcc -I../../../work/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -o avx_savms64_s.o -MT avx_savms64_s.o -MD -MP -MF avx_savms64_s.dep -DSHARED -c -xassembler-with-cpp ../../../work/libgcc/config/i386/avx_savms64.S
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm15,-0x30(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm14,-0x20(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm13,-0x10(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm12, (%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm11, 0x10(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm10, 0x20(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm9, 0x30(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm8, 0x40(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm7, 0x50(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps %xmm6, 0x60(%rax)'
make[3]: *** [avx_savms64_s.o] Error 1

Dominique

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-09-22  8:28 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-14  3:57 [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV Daniel Santos
2017-09-17 15:53 ` Uros Bizjak
2017-09-17 21:56   ` Daniel Santos
2017-09-19 12:13     ` Rainer Orth
2017-09-19 13:33       ` Uros Bizjak
2017-09-19 13:36         ` Rainer Orth
2017-09-19 20:57       ` Daniel Santos
2017-09-18 15:17 Dominique d'Humières
2017-09-18 23:04 ` Daniel Santos
2017-09-19  6:10   ` Uros Bizjak
2017-09-19  6:58   ` Jakub Jelinek
2017-09-19 20:07     ` Daniel Santos
2017-09-21  1:52     ` Daniel Santos
2017-09-21  6:20       ` Uros Bizjak
2017-09-21 16:14       ` Rainer Orth
2017-09-21 22:12         ` Daniel Santos
2017-09-22  2:42           ` Daniel Santos
2017-09-22  7:43             ` Rainer Orth
2017-09-22  8:21               ` Daniel Santos
2017-09-22  8:28                 ` Rainer Orth

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).