[PATCH v3 3/5] tcg: Elide memory barriers implied by the host memory model

Richard Henderson posted 5 patches 2 years, 7 months ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Riku Voipio <riku.voipio@iki.fi>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
[PATCH v3 3/5] tcg: Elide memory barriers implied by the host memory model
Posted by Richard Henderson 2 years, 7 months ago
Reduce the set of required barriers to those needed by
the host right from the beginning.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/tcg-op.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index 7aadb37756..574001c221 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -115,7 +115,11 @@ void tcg_gen_mb(TCGBar mb_type)
 #endif
 
     if (parallel) {
-        tcg_gen_op1(INDEX_op_mb, mb_type);
+        /* We can elide anything which the host provides for free. */
+        mb_type &= ~TCG_TARGET_DEFAULT_MO;
+        if (mb_type & TCG_MO_ALL) {
+            tcg_gen_op1(INDEX_op_mb, mb_type);
+        }
     }
 }
 
-- 
2.34.1