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

Reply via email to