I think the question here is whether an UNSPEC_VOLATILE should always
be a memory barrier. A volatile asm is not a memory barrier unless it
has an explicit clobber of "memory". It's reasonably easy to make any
instruction which uses UNSPEC_VOLATILE be a memory barrier by adding
(clobber (mem:blk (scratch)).
There is a comment just below the area my patch touches:
/* Traditional and volatile asm instructions must be considered to use
and clobber all hard registers, all pseudo-registers and all of
memory. So must TRAP_IF and UNSPEC_VOLATILE operations.
Consider for instance a volatile asm that changes the fpu rounding
mode. An insn should not be moved across this even if it only uses
pseudo-regs because it might give an incorrectly rounded result. */
Despite that comment, I believe that we do currently permit moving
instructions which only have memory operands across volatile asm
instructions which do not explicitly clobber memory.
If you want UNSPEC_VOLATILE and volatile asm instructions to act the
same way, then your patch is incomplete, since it only changes the
behaviour of UNSPEC_VOLATILE.