Lower idempotent RMWs to fence+load
authorRobin Morisset <morisset@google.com>
Thu, 25 Sep 2014 17:27:43 +0000 (17:27 +0000)
committerRobin Morisset <morisset@google.com>
Thu, 25 Sep 2014 17:27:43 +0000 (17:27 +0000)
commit79826e015e33c24802bf4d2cc6e54286c39b2d44
tree0da3d5a6c9f34fb6be4e2b64e6706937bd9f14c8
parent837a7c094b56019c6103dd37297077a28e5350c9
Lower idempotent RMWs to fence+load

Summary:
I originally tried doing this specifically for X86 in the backend in D5091,
but it was rather brittle and generally running too late to be general.
Furthermore, other targets may want to implement similar optimizations.
So I reimplemented it at the IR-level, fitting it into AtomicExpandPass
as it interacts with that pass (which could not be cleanly done before
at the backend level).

This optimization relies on a new target hook, which is only used by X86
for now, as the correctness of the optimization on other targets remains
an open question. If it is found correct on other targets, it should be
trivial to enable for them.

Details of the optimization are discussed in D5091.

Test Plan: make check-all + a new test

Reviewers: jfb

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5422

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218455 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Target/TargetLowering.h
lib/CodeGen/AtomicExpandPass.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h
test/CodeGen/X86/atomic_idempotent.ll [new file with mode: 0644]