[PATCH] X86: rework expansion of atomic instructions

Tim Northover t.p.northover at gmail.com
Mon Jun 16 08:37:36 PDT 2014


Hi all,

This is a patch very much along the lines of the recent ARM & AArch64 refactoring of atomics: it moves the complex control-flow (& naive instruction selection) logic out of the MachineInstr level and into IR proper. It has many of the same benefits:

+ More efficient code since the ISel phase can see when constants are used (for example).
+ Neater code

That said, the primary purpose is to support 128-bit atomic operations on x86_64 (hence the added test). These benefits mostly come about because it's the easiest way to do so.

It would have been good to completely reuse the existing LoadLinked pass, instead of copy/paste/adapt, but unfortunately the constraints and optimal forms don't *quite* match up between x86 and LL/SC architectures, so I've added it as an x86-specific pass.

The other detail that may need explaining is the removal of NOCMOV checks in atomic-minmax-i6432.ll: it turns out that any CPU with cmpxchg8b will have cmov, and they can't be controlled independently in LLVM. Since this test is fundamentally about cmpxchg8b, I decided to simply remove those tests.

Do the changes look OK, and are people who more frequently fiddle around with x86 happy with the direction?

Cheers.

Tim.

http://reviews.llvm.org/D4160

Files:
  lib/Target/X86/CMakeLists.txt
  lib/Target/X86/X86.h
  lib/Target/X86/X86AtomicExpandPass.cpp
  lib/Target/X86/X86ISelDAGToDAG.cpp
  lib/Target/X86/X86ISelLowering.cpp
  lib/Target/X86/X86ISelLowering.h
  lib/Target/X86/X86InstrCompiler.td
  lib/Target/X86/X86InstrInfo.td
  lib/Target/X86/X86TargetMachine.cpp
  test/CodeGen/X86/2010-01-08-Atomic64Bug.ll
  test/CodeGen/X86/Atomics-64.ll
  test/CodeGen/X86/atomic-load-store-wide.ll
  test/CodeGen/X86/atomic-minmax-i6432.ll
  test/CodeGen/X86/atomic128.ll
  test/CodeGen/X86/atomic16.ll
  test/CodeGen/X86/atomic32.ll
  test/CodeGen/X86/atomic64.ll
  test/CodeGen/X86/atomic6432.ll
  test/CodeGen/X86/atomic8.ll
  test/CodeGen/X86/atomic_op.ll
  test/CodeGen/X86/pr5145.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4160.10448.patch
Type: text/x-patch
Size: 90960 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140616/e08014ef/attachment.bin>


More information about the llvm-commits mailing list