[Bug target/95750] [x86] Use dummy atomic insn instead of mfence in __atomic_thread_fence(seq_cst)

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jul 23 20:42:52 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95750

--- Comment #15 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Joseph C. Sible from comment #14)
> I notice this change affects -Os too, even though "lock orq $0,(%rsp)" is 6
> bytes and "mfence" is only 3 bytes.

Yes, we can emit mfence for -Os. I'm testing the following patch:

--cut here--
diff --git a/gcc/config/i386/sync.md b/gcc/config/i386/sync.md
index c88750d3664..ed17bb00205 100644
--- a/gcc/config/i386/sync.md
+++ b/gcc/config/i386/sync.md
@@ -123,7 +123,8 @@
       rtx mem;

       if ((TARGET_64BIT || TARGET_SSE2)
-         && !TARGET_AVOID_MFENCE)
+         && (optimize_function_for_size_p (cfun)
+             || !TARGET_AVOID_MFENCE))
        mfence_insn = gen_mfence_sse2;
       else
        mfence_insn = gen_mfence_nosse;
--cut here--


More information about the Gcc-bugs mailing list