Is there an example, not necessarily for atomic_exchange, that I can follow ? Also, is this behavior related to GCC memory model ? ie: (MEM_VOLATILE_P (operands[1])) for atomic_exchange always TRUE regardless of whether the memory operand was declared using "volatile". On Tue, Sep 10, 2019 at 4:18 AM Oleg Endo <oleg.endo@xxxxxxxxxxx> wrote: > > On Mon, 2019-09-09 at 15:40 -0500, William Tambe wrote: > > I use documentation for atomic_exchange from: > > https://gcc.gnu.org/onlinedocs/gccint/Standard-Names.html#Standard-Names > > > > When defining machine description for atomic_exchange, I find that GCC > > mark operands[1] as volatile such that (MEM_VOLATILE_P (operands[1])) > > returns TRUE; even when the memory operand is not declared using the C > > keyword "volatile". > > > > Is there a way to have atomic_exchange not marking operands[1] as > > volatile unless the memory operand was declared volatile ? > > If you want to distinguish that, one way is to implement all atomic > patterns in the backedn. Then you know that those come from > __atomic__... calls. In the other patterns, you can then assume that > MEM_VOLATILE_P must be a mem ref for everything else (that is > considered a volatile mem ref). > > Cheers, > Oleg >