Skip to content

Commit 48d552e

Browse files
ubizjakUros Bizjak
authored andcommitted
re PR target/91719 (gcc compiles seq_cst store on x86-64 differently from clang/icc)
PR target/91719 * config/i386/i386.h (TARGET_USE_XCHG_FOR_ATOMIC_STORE): New macro. * config/i386/x86-tune.def (X86_TUNE_USE_XCHG_FOR_ATOMIC_STORE): New. * config/i386/sync.md (atomic_store<mode>): emit XCHG for TARGET_USE_XCHG_FOR_ATOMIC_STORE. From-SVN: r275754
1 parent e4ab9e0 commit 48d552e

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

gcc/ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2019-09-16 Uroš Bizjak <ubizjak@gmail.com>
2+
3+
PR target/91719
4+
* config/i386/i386.h (TARGET_USE_XCHG_FOR_ATOMIC_STORE): New macro.
5+
* config/i386/x86-tune.def (X86_TUNE_USE_XCHG_FOR_ATOMIC_STORE): New.
6+
* config/i386/sync.md (atomic_store<mode>): emit XCHG for
7+
TARGET_USE_XCHG_FOR_ATOMIC_STORE.
8+
19
2019-09-16 Jason Merrill <jason@redhat.com>
210

311
* Makefile.in (build/genmatch.o): Depend on $(CPPLIB_H).

gcc/config/i386/i386.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@ extern unsigned char ix86_tune_features[X86_TUNE_LAST];
590590
ix86_tune_features[X86_TUNE_AVOID_FALSE_DEP_FOR_BMI]
591591
#define TARGET_ONE_IF_CONV_INSN \
592592
ix86_tune_features[X86_TUNE_ONE_IF_CONV_INSN]
593+
#define TARGET_USE_XCHG_FOR_ATOMIC_STORE \
594+
ix86_tune_features[X86_TUNE_USE_XCHG_FOR_ATOMIC_STORE]
593595
#define TARGET_EMIT_VZEROUPPER \
594596
ix86_tune_features[X86_TUNE_EMIT_VZEROUPPER]
595597

gcc/config/i386/sync.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,11 @@
306306
{
307307
operands[1] = force_reg (<MODE>mode, operands[1]);
308308

309-
/* For seq-cst stores, when we lack MFENCE, use XCHG. */
310-
if (is_mm_seq_cst (model) && !(TARGET_64BIT || TARGET_SSE2))
309+
/* For seq-cst stores, use XCHG
310+
when we lack MFENCE or when target prefers XCHG. */
311+
if (is_mm_seq_cst (model)
312+
&& (!(TARGET_64BIT || TARGET_SSE2)
313+
|| TARGET_USE_XCHG_FOR_ATOMIC_STORE))
311314
{
312315
emit_insn (gen_atomic_exchange<mode> (gen_reg_rtx (<MODE>mode),
313316
operands[0], operands[1],

gcc/config/i386/x86-tune.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ DEF_TUNE (X86_TUNE_ONE_IF_CONV_INSN, "one_if_conv_insn",
313313
m_SILVERMONT | m_KNL | m_KNM | m_INTEL | m_CORE_ALL | m_GOLDMONT
314314
| m_GOLDMONT_PLUS | m_TREMONT | m_GENERIC)
315315

316+
/* X86_TUNE_USE_XCHG_FOR_ATOMIC_STORE: Use xchg instead of mov+mfence. */
317+
DEF_TUNE (X86_TUNE_USE_XCHG_FOR_ATOMIC_STORE, "use_xchg_for_atomic_store",
318+
m_CORE_ALL | m_BDVER | m_ZNVER | m_GENERIC)
319+
316320
/*****************************************************************************/
317321
/* 387 instruction selection tuning */
318322
/*****************************************************************************/

0 commit comments

Comments
 (0)