[PATCH] D129947: [X86] Prefer `lock or` over mfence.

Valentin Churavy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 16 17:20:04 PDT 2022


vchuravy created this revision.
vchuravy added a reviewer: reames.
Herald added subscribers: jsji, pengfei, hiraditya.
Herald added a project: All.
vchuravy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

LLVM currently emits `mfence` for `__atomic_thread_fence(seq_cst)`. On
modern CPUs `lock or` is more efficient and provides the same sequential
consistency. GCC 11 made this switch as well (see https://gcc.gnu.org/pipermail/gcc-cvs/2020-July/314418.html)
and https://reviews.llvm.org/D61863 and https://reviews.llvm.org/D58632
moved into this direction as well, but didn't touch `fence seq_cst`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129947

Files:
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86TargetTransformInfo.h
  llvm/test/CodeGen/X86/atomic-unordered.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129947.445275.patch
Type: text/x-patch
Size: 11145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220717/8b11fa2a/attachment.bin>


More information about the llvm-commits mailing list