[X86] Allow atomic operations using immediates to avoid using a register
authorRobin Morisset <morisset@google.com>
Tue, 2 Sep 2014 22:16:29 +0000 (22:16 +0000)
committerRobin Morisset <morisset@google.com>
Tue, 2 Sep 2014 22:16:29 +0000 (22:16 +0000)
commit76b55cc4b19b4843189525faa52c20b01ff7aa24
treef459ec2d274edddeea5fbc48e1dcce1a2af5300d
parentba709096bc0c98afa8665aa4db45b73dabf68ab6
[X86] Allow atomic operations using immediates to avoid using a register

The only valid lowering of atomic stores in the X86 backend was mov from
register to memory. As a result, storing an immediate required a useless copy
of the immediate in a register. Now these can be compiled as a simple mov.

Similarily, adding/and-ing/or-ing/xor-ing an
immediate to an atomic location (but through an atomic_store/atomic_load,
not a fetch_whatever intrinsic) can now make use of an 'add $imm, x(%rip)'
instead of using a register. And the same applies to inc/dec.

This second point matches the first issue identified in
  http://llvm.org/bugs/show_bug.cgi?id=17281

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216980 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86CodeEmitter.cpp
lib/Target/X86/X86InstrCompiler.td
lib/Target/X86/X86MCInstLower.cpp
test/CodeGen/X86/atomic_mi.ll [new file with mode: 0644]