[InstCombine] Optimize `atomicrmw <op>, 0` into `load atomic` when possible

Authored by qcolombet on Feb 7 2019, 1:27 PM.


[InstCombine] Optimize atomicrmw <op>, 0 into load atomic when possible

This commit teaches InstCombine how to replace an atomicrmw operation
into a simple load atomic.
For a given atomicrmw <op>, this is possible when:

  1. The ordering of that operation is compatible with a load (i.e., anything that doesn't have a release semantic).
  2. <op> does not modify the value being stored

Differential Revision: https://reviews.llvm.org/D57854

llvm-svn: 353471