[PATCH] D141277: [InstCombine] Don't optimize idempotent `atomicrmw <op>, 0` into `load atomic`

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 05:33:41 PST 2023


qcolombet created this revision.
qcolombet added reviewers: jfb, reames, JonChesterfield.
Herald added a subscriber: hiraditya.
Herald added a project: All.
qcolombet requested review of this revision.
Herald added a project: LLVM.

Turning idempotent `atomicrmw`s into `load atomic` is perfectly legal
with respect to how the loading happens, but it may not be legal for the
whole program semantic.

Indeed, this optimization removes a store that may have some effects on
the legality of other optimizations.
Essentially, we lose some information and depending on the backend
it may or may not produce incorrect code, so don't do it!

This fixes llvm.org/PR56450.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141277

Files:
  llvm/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp
  llvm/test/Transforms/InstCombine/atomicrmw.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141277.487396.patch
Type: text/x-patch
Size: 5991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230109/a4e56b5b/attachment.bin>


More information about the llvm-commits mailing list